UserControl with Javascript disappears after ENTER

G

Guest

I have a UserControl that builds a Tree-View Menu using Javascript. This UC does not run as a ServerControl
Then, in every aspx page I include this UC. Everything works perfect, except that if I press ENTER on a aspx, the "Menu" (means, the UserControl) disappears. Of course I can prevent pressing Enter - but the same problem still happens when I try to initialize all Textboxes using this code
private void ClearTextBoxes(Control parent)

foreach (Control c in parent.Controls)

TextBox tb = c as TextBox
if (tb != null)
tb.Text=""
if (c.HasControls()
ClearTextBoxes(c)



I should be able to make UC loaded (and the Javascript that it contains runing) again. Is there a way to do this ?
 
S

Steven Cheng[MSFT]

Hi,

Thanks for posting in the community!
From your description, you have a custom UserControl( a javascript based
treeview menu). You include it in many ASP.NET web pages. However, you
found that when you press "enter" key, the menu will disappear, yes?

As for this problem, I'd like to confirm some further things on it:
1. Is the UserControl you mean the "ASCX" usercontrol?

2. If is a ascx usercontrol. How do you add it into page. Add it statically
in the page's source template or use Page.LoadControl to dynamically add it?

3. Does the problem occur on other UserControls? Or is it possible that you
generate a simple page to repro this problem? If so, we can try repro on my
side and do some further research on the issue.

Please check out the above things. If you feel anything unclear or have any
new findings, please feel free to post here.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
G

Guest

Steven
1) yes, it is a ascx user contro
2) I loaded it statically, means "dragging" the control into my aspx page during desig
3) I don't use other ascx controls at the moment (it is still a very small app)
 
S

Steven Cheng[MSFT]

Hi,

Thanks for your response. Since the UserControl is statically added. I
think the problem may concerned with the certain UserControl. Also, I also
suspect whether the "private void ClearTextBoxes(Control parent)" fuction
cause this problem. Would you please try comment(remove) the calling of the
"ClearTextBoxes" mehtod in any posted back event in the page. Or you may
check the page to see whether there are any other functions may access the
control collecdtions of the page, if so, also comment them to see whether
the problem remains.

If the problem still remains after the above steps. Would you provide me a
demo page( with the certain usercontrol) which can repro this problem so
that we can try repro it and do some fruther troubleshooting on our side.
Thanks.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
S

Steven Cheng[MSFT]

Hi Carlo,

Thanks for your followup. I'm glad that you've figured out the problem.
Also, next time if you have any problem or questions, please always feel
free to post in community. We're willing to help you.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top