CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 4/9/2004 2:52:51 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 14 Views: 24 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
15 Items, 1 Pages 1 |< << Go >> >|
Bans.Net
Asp.Net User
Problem with Font property of custom web control4/9/2004 2:52:51 AM

0/0

I am facing a problem with the Font property of my Composite Custom Web Control.

I have built a composite control with textboxes, labels and buttons.

Following are the code and the error details:

 

Private _loginidlabelfont As Font

'Other code

Public Property LoginIdLabelFont() As Font
Get
Return _loginidlabelfont
End Get
Set(ByVal Value As Font)
_loginidlabelfont = Value
End Set
End Property

'Other code

Protected Overrides Sub CreateChildControls()

'Other Code
Dim lblLoginId As New Label()
lblLoginId.Text = _loginidlabel
lblLoginId.BackColor = _labelbackcolor
lblLoginId.ForeColor = _labelforecolor
lblLoginId.Font.Name = _loginidlabelfont.Name

lblLoginId.Font.Bold = _loginidlabelfont.Bold
lblLoginId.Font.Italic = _loginidlabelfont.Italic
lblLoginId.Font.Underline = _loginidlabelfont.Underline
lblLoginId.Font.Size = convertfont.Point(_loginidlabelfont.Size)

'Other Code


Now I am using the composite control in a Web Application.
In the property sheet for the control I get the LoginIdLabelFont() property.
The problem comes when I select multiple styles (Bold, Underline, Italic, Strikeout).
If I select only one of them, it works fine. But, If I select any 2 or more then it gives me an error message:

-----------------------------------------------------------------------------
Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
-----------------------------------------------------------------------------

Can anybody help me with this?

BR,
Bans.
master4eva
Asp.Net User
Re: Problem with Font property of custom web control4/9/2004 9:04:12 AM

0/0

Can you give us the source line of error?
-- Justin Lovell
FancyKetsup
Asp.Net User
Re: Problem with Font property of custom web control4/9/2004 9:38:18 AM

0/0

Can you post your property declarations for these as well? I suspect what is happening is that your setting a font property for one of your child controls and it doesn't have the correctly mapped field to it.... Check your mappings back to your field declarations carefully. You will probably find one that maps back to another controls font properties that isn't ever initialized.
Answering a question increases your knowledge asking a question shows your Intelligence!
Bans.Net
Asp.Net User
Re: Problem with Font property of custom web control4/9/2004 10:10:59 AM

0/0

Justin:

Its surprising but its not giving any line number... I am getting this error when I am executing my Web Application, which contains nothing else but this Composite Control.
Bans.Net
Asp.Net User
Re: Problem with Font property of custom web control4/9/2004 10:21:14 AM

0/0

Fancy:

Below are the Property declarations for the other properties, but, the problem I am facing only when I am specifying two or more styles (Bold, Italic, Underline & Strikeout) in the Web Application where I am using this Composite Control.




Private _labelbackcolor As Color
Private _loginidlabel As String
Private _labelforecolor As Color


Public Property LoginIdLabelText() As String
Get
Return _loginidlabel
End Get
Set(ByVal Value As String)
_loginidlabel = Value
End Set
End Property

Public Property LabelForeColor() As Color
Get
Return _labelforecolor
End Get
Set(ByVal Value As Color)
_labelforecolor = Value
End Set
End Property

Public Property LabelBackColor() As Color
Get
Return _labelbackcolor
End Get
Set(ByVal Value As Color)
_labelbackcolor = Value
End Set
End Property



Is there a way to specify each part of the Font property(Style, Color, Size, etc) individually??

BR,
Bans
master4eva
Asp.Net User
Re: Problem with Font property of custom web control4/9/2004 11:12:05 AM

0/0

:: I suspect what is happening is that your setting a font property for one of your child controls and it doesn't have the correctly mapped field to it....

If it was throwing an exception to that, it would throw a syntax error and it will give you a line problem. Because it is not giving the source line of the error, either of the two are happening:

1) Your user control is compiled into release mode by ASP.NET (configured on the Page declaration or alternatively in the web.config for site wide configuration).

2) The error is being thrown out of your scope of the user control. If it is this, then the stack trace will become extremely *valuable*.

The easiest to check first with the first one. If it is this, switch on debugging and tell ASP.NET to compile into "debug" mode. That is the fastest as well. However, I suspect it is alternative two but without the first step, I cannot say for sure if it is an error that is happening internally.
-- Justin Lovell
Bans.Net
Asp.Net User
Re: Problem with Font property of custom web control4/9/2004 12:03:07 PM

0/0

Justin,

The first case is not true... The user control has been compiled in the Debug mode itself.

Bans
master4eva
Asp.Net User
Re: Problem with Font property of custom web control4/9/2004 5:53:17 PM

0/0

Ok, starting to fall into place. Can you give the stack trace of the error?
-- Justin Lovell
FancyKetsup
Asp.Net User
Re: Problem with Font property of custom web control4/9/2004 10:14:50 PM

0/0

Bans I am going to take a guess here and say that asp.net server controls are not able to work with the system.drawing.font object in the way that your trying to use it. It would be interesting to see how that acts in a winform. If the inherited property "Font" that comes from webcontrol isn't going to work for you then I suggest just allowing for a Font name then create bool drop downs for the styles. I have played with the system.drawing.font object in the property browser before and I am not sure if that is a bug or if it works as designed. But I do know that no matter what you do your going to get an error if you pick more than one font-style. If you figure it out I would be glad to hear about how you got around it. Only thing I can think of is to just use it in a way to persist some code to the Initialization() while in design-mode that you could come back and use at runtime. Because embedding that font information into an html tag is going to generate and error if more than one style is chosen.
Answering a question increases your knowledge asking a question shows your Intelligence!
Bans.Net
Asp.Net User
Re: Problem with Font property of custom web control4/10/2004 8:48:58 AM

0/0

Here is the Rest of the error message:

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
System.Web.Compilation.CodeDomUtility.GenerateExpressionForValue(PropertyInfo propertyInfo, Object value, Type valueType) +2171
System.Web.Compilation.CodeDomUtility.GenerateExpressionForValue(PropertyInfo propertyInfo, Object value, Type valueType) +1213
System.Web.Compilation.CodeDomUtility.GenerateExpressionForValue(PropertyInfo propertyInfo, Object value, Type valueType) +1503
System.Web.Compilation.TemplateControlCompiler.BuildBuildMethod(ControlBuilder builder, Boolean fTemplate, PropertySetterEntry pse) +2549
System.Web.Compilation.TemplateControlCompiler.BuildSourceDataTreeFromBuilder(ControlBuilder builder, Boolean fInTemplate, PropertySetterEntry pse) +794
System.Web.Compilation.TemplateControlCompiler.BuildSourceDataTreeFromBuilder(ControlBuilder builder, Boolean fInTemplate, PropertySetterEntry pse) +352
System.Web.Compilation.TemplateControlCompiler.BuildSourceDataTreeFromBuilder(ControlBuilder builder, Boolean fInTemplate, PropertySetterEntry pse) +352
System.Web.Compilation.TemplateControlCompiler.BuildMiscClassMembers() +52
System.Web.Compilation.PageCompiler.BuildMiscClassMembers() +10
System.Web.Compilation.BaseCompiler.BuildSourceDataTree() +1276
System.Web.Compilation.BaseCompiler.GetCompiledType() +129
System.Web.UI.PageParser.CompileIntoType() +60
System.Web.UI.TemplateParser.GetParserCacheItemThroughCompilation() +124

[HttpException (0x80004005): Object reference not set to an instance of an object.]
System.Web.UI.TemplateParser.GetParserCacheItemInternal(Boolean fCreateIfNotFound) +692
System.Web.UI.TemplateParser.GetParserCacheItemWithNewConfigPath() +125
System.Web.UI.TemplateParser.GetParserCacheItem() +88
System.Web.UI.TemplateControlParser.CompileAndGetParserCacheItem(String virtualPath, String inputFile, HttpContext context) +116
System.Web.UI.TemplateControlParser.GetCompiledInstance(String virtualPath, String inputFile, HttpContext context) +36
System.Web.UI.PageParser.GetCompiledPageInstanceInternal(String virtualPath, String inputFile, HttpContext context) +43
System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String path) +44
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, String path, String pathTranslated, Boolean useAppConfig) +699
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +95
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +173




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
master4eva
Asp.Net User
Re: Problem with Font property of custom web control4/10/2004 10:05:43 AM

0/0

I am starting to suspect it is an error on your page... the problem is possibly not in the control. Check it out by commenting out the lines in your control. When you are left with almost nothing, you will know that the problem is on the page.
-- Justin Lovell
FancyKetsup
Asp.Net User
Re: Problem with Font property of custom web control4/11/2004 11:22:07 AM

0/0

The problem is in serializing of the html. When you implement it the way you have it serializes the html attributes of the font into the tag of your control... which is fine and dandy with the exception that it should not serialize the property itself just the sub-properties. Try it! Set 2-3 sub-properties but then go back to html view and take out the property itself but leave the sub-properties and you will see it works fine, for the life of me I have never figured out how to do it (just serialize sub-properties). That?s how the Font property works in the property browser it serializes just sub-properties but not the Font property itself. You do have to set [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)] on the property to get the sub properties serialized but the problem is it still serializes the parent also.
Answering a question increases your knowledge asking a question shows your Intelligence!
Bans.Net
Asp.Net User
Re: Problem with Font property of custom web control4/12/2004 6:03:58 AM

0/0

Justin:

Do you want me to comment out just the 'Protected Overrides Sub CreateChildControls()' Sub procedure or the whole code of the control (the property declaration, etc)??

If I comment the property declarations then I wont get the error. On commenting just the 'Protected Overrides Sub CreateChildControls()' sub procedure I am getting the same error.

Bans.Net
Asp.Net User
Re: Problem with Font property of custom web control4/12/2004 6:20:44 AM

0/0

Fancy:

I am afraid, I am very new to .Net - I dont know how to Serialize the property...
Please help me with an example...

Thanks,
Bans
master4eva
Asp.Net User
Re: Problem with Font property of custom web control4/13/2004 7:35:04 PM

0/0

Ok, why don't you drill down to a specific block of code. You know that you are having troubles with the properties... so drill down which propert(y/ies) are giving the hassle. For some gut feeling, I do not think that the null value is accepted.

Otherwise, I would like to know how you are setting the values? Also, I would like to know the source file name that is throwing the error? (it is found between the stack trace and the source line).
-- Justin Lovell
15 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Developing Microsoft ASP.NET Server Controls and Components Authors: Nikhil Kothari, Vandana Datye, Pages: 689, Published: 2002
Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
ASP.NET Kick Start: Kick Start Authors: Stephen Walther, Pages: 624, Published: 2002
Pro .NET 2.0 Windows Forms and Custom Controls in C#: From Professional to Expert Authors: Matthew MacDonald, Pages: 1037, Published: 2005
Pro ASP.NET 2.0 in C# 2005: Create Next-generation Web Applications with the Latest Version of Microsoft's Revolutionary Technology Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1426, Published: 2006
Pro ASP.NET 3.5 in C# 2008 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1498, Published: 2007
Pro ASP.NET 2.0 in C# 2005 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1255, Published: 2005
Beginning ASP.NET 2.0 in VB 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1063, Published: 2006
Essential ASP. NET with Examples in C#: With Examples in C# Authors: Fritz Onion, Pages: 393, Published: 2003
Pro ASP. Net 3. 5 Server Controls and AJAX Components Authors: Rob Cameron, Dale Michalk, Pages: 740, Published: 2008

Web:
WebArchitect.pl Blog » Blog Archive » ASP.NET custom WebControl ... Mar 24, 2008 ... After hours spending surfing on the web for solution of my problem with custom fonts list property in web control, finally I’ve found an ...
WebControl.Font Property (System.Web.UI.WebControls) Gets the font properties associated with the Web server control. .... Web Server Control Syntax · Developing Custom ASP.NET Server Controls ...
CodeProject: XP Style Navigation Bar Server Control with ... I need collapsible property for custom control just like as every control has ' font' property. I show this but it is not matched with my requirement. ...
Web Custom Control, Property Nesting - .NET - tribe.net This class contains Font, ForeColor, and CssClass. The Font property is designed ... Re: Web Custom Control, Property Nesting. Sun, May 15, 2005 - 12:30 PM ...
A custom server control property - ASP.NET Forums I am trying to develop the following custom server control: ... HoverImageUrl and SelectedImageUrl, like I do with the font property. ...
CoDe Magazine - Article: Custom Web Controls Demystified, Part 2 I explained that the Style object contains properties such as Font, ... are still contained within the Web control’s class, the actual custom Web control, ...
Custom Server Control Syntax You can then declare the property in the opening tag of the server control as font-name = "Arial" . For more information about developing custom server ...
Developing a Simple ASP.NET Server Control WebControl so that your control can inherit UI-specific properties. ... NET page uses the custom control created in the preceding example. ...
ASP.NET.4GuysFromRolla.com: A Custom ASP.NET Server Control for ... Oct 29, 2003 ... To solve this problem I decided to create a custom ASP. .... the declarative syntax for the RssFeed control with a number of properties set ...
ASP.NET Resources - Weather Custom Server Control This is not an article on how to write a templated custom server control. .... When the control encounters a problem during its initialization, ...

Videos:
XML11: An Abstract Windowing Protocol Google TechTalks June 1, 2006 Arno Puder Arno Puder received his masters and Ph.D. in computer science and is currently working as an ...




Search This Site:










validation ??

loop through a class and get all public strings

something like smartnavigation

re: moduler programming

sqlxml

problems setting up the portal on isp

smtp service?

application push download on client side

i need .net framework concept

asp.net 2.0 seo help

problem with a c# to vb translation

command.open()/connection.open()

help with logic

droplist item add blank.

deployment of web applications

select a specific printer to print word doc

what is the proper way to handle errors in asp.net?

comment box sidebar

what’s the difference between response.write() andresponse.output.write()?

simple page counter using asp.net not asp

accessing my localhost pages from another machine while debugging

import users from ldap

wroking with html output as a string ???

deploying to win server 2003 sp2 and sql server 2005 sp2

c# vs vb.net

onblur?

asp.net database created at for memebership logan

a standardized method to access to controls that are within a templated control.

checkboxes in a datagrid

generate an alert message

  Privacy | Contact Us
All Times Are GMT