Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Very Strange Problem! (Derived Controls) - Help!

Reply
Thread Tools

Very Strange Problem! (Derived Controls) - Help!

 
 
Sosh
Guest
Posts: n/a
 
      01-13-2006
Hi,

I'm pulling my hair out trying to work this out. Pehaps I am
missunderstanding something - hopefully someone can shed some light on this:

1) I have a class library that contains a bunch of custom web controls. Two
of these controls are derived from the TextBox control, and overide the
onLoad method in order to add some client side attributes, eg:

namespace SomeControls{

public class Control1 : System.Web.UI.WebControls.TextBox

{
public Control1 ()
{
}

protected override void OnLoad(EventArgs e)
{
this.Attributes["onblur"] = "some javascript";
base.OnLoad(e);
}
}

}

AND.........

namespace SomeControls{

public class Control2 : System.Web.UI.WebControls.TextBox

{
public Control2 ()
{
}

protected override void OnLoad(EventArgs e)
{
this.Attributes["onfocus"] = "some other javascript";
base.OnLoad(e);
}
}

}

2) I have a some user controls, that contain the custom controls, which are
added Declaratively

3) I Dynamically load one of the user controls into my page depending on
certain factors.



My problem is this: When the page is rendered, some of the custom controls
are rendered incorrectly - they seem to be taking elements from each of the
controls that derive from the TextBox control. For instance, a control that
was declared as SomeControls:Control1 will be rendered with the attributes
from BOTH SomeControls:Control1 and SomeControls:Control2. (eg both the
onBlur and onFocus attributes) !!? To add to the strangeness, sometimes
this happens, and sometimes this does not - If there are 10 instances of
SomeControls:Control1 on the page, sometimes the top who will contain the
elements from SomeControls:Control1 and SomeControls:Control2, while the
rest will render correctly with just the SomeControls:Control1 code.

Its like the two classes SomeControls:Control1 and SomeControls:Control2 are
interfereing with each other somehow.

I hope this makes some sense - it's pretty hard to explain, and personally I
am loosing faith that I can figure out what is going on here. Can someone
exlplain? Please!

Thanks V much

S





 
Reply With Quote
 
 
 
 
Karl Seguin [MVP]
Guest
Posts: n/a
 
      01-13-2006
I understand what you are explaining, but i've never seen this behavior, and
I'm not sure what could possibly be the cause. Any chance of zipping up a
simplified example and sending it to my email (it's somewhat obfuscated, but
you can figure it out .

Karl

--
http://www.openmymind.net/



"Sosh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I'm pulling my hair out trying to work this out. Pehaps I am
> missunderstanding something - hopefully someone can shed some light on
> this:
>
> 1) I have a class library that contains a bunch of custom web controls.
> Two of these controls are derived from the TextBox control, and overide
> the onLoad method in order to add some client side attributes, eg:
>
> namespace SomeControls{
>
> public class Control1 : System.Web.UI.WebControls.TextBox
>
> {
> public Control1 ()
> {
> }
>
> protected override void OnLoad(EventArgs e)
> {
> this.Attributes["onblur"] = "some javascript";
> base.OnLoad(e);
> }
> }
>
> }
>
> AND.........
>
> namespace SomeControls{
>
> public class Control2 : System.Web.UI.WebControls.TextBox
>
> {
> public Control2 ()
> {
> }
>
> protected override void OnLoad(EventArgs e)
> {
> this.Attributes["onfocus"] = "some other javascript";
> base.OnLoad(e);
> }
> }
>
> }
>
> 2) I have a some user controls, that contain the custom controls, which
> are added Declaratively
>
> 3) I Dynamically load one of the user controls into my page depending on
> certain factors.
>
>
>
> My problem is this: When the page is rendered, some of the custom
> controls are rendered incorrectly - they seem to be taking elements from
> each of the controls that derive from the TextBox control. For instance,
> a control that was declared as SomeControls:Control1 will be rendered with
> the attributes from BOTH SomeControls:Control1 and SomeControls:Control2.
> (eg both the onBlur and onFocus attributes) !!? To add to the
> strangeness, sometimes this happens, and sometimes this does not - If
> there are 10 instances of SomeControls:Control1 on the page, sometimes the
> top who will contain the elements from SomeControls:Control1 and
> SomeControls:Control2, while the rest will render correctly with just the
> SomeControls:Control1 code.
>
> Its like the two classes SomeControls:Control1 and SomeControls:Control2
> are interfereing with each other somehow.
>
> I hope this makes some sense - it's pretty hard to explain, and personally
> I am loosing faith that I can figure out what is going on here. Can
> someone exlplain? Please!
>
> Thanks V much
>
> S
>
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very very very basic question Peter C Programming 14 02-14-2005 09:46 AM
very very very long integer shanx__=|;- C Programming 19 10-19-2004 03:55 PM
very very very long integer Abhishek Jha C Programming 4 10-17-2004 08:19 AM
Quick Book file access very very very slow Thomas Reed Computer Support 7 04-09-2004 08:09 PM
very Very VERY dumb Question About The new Set( ) 's Raymond Arthur St. Marie II of III Python 4 07-27-2003 12:09 AM



Advertisments