Default Button: RegisterHiddenField

J

John Smith

I am having a brain fart today....

How do you set a default button within a User Control? I am using
"Page.RegisterHiddenField("__EVENTTARGET", "btnSubmit")" but it does not
seem to be working for me.

I have another User Control which uses this technique and works. Can't
think of what I am missing?
 
G

Grant Merwitz

Check the name of the Button through the Html Source (in IE)
When you register a control on your page, it renames your controls with
[ControlTagName]_[IDYOUSET]
you can pick this up by viewing source from IE, and viewing the now changed
ID of your button 'btnsubmit'

to fix this, just change your javascript with the new id
"Page.RegisterHiddenField("__EVENTTARGET", "[TAGNAME]_btnSubmit")"
Bearing in mind for this solution, you'll need to give the control the same
tagname wherever you use it - unless the javascript is in the page and not
the control

HTH
 
A

Andrea Zani

John Smith said:
I am having a brain fart today....

How do you set a default button within a User Control? I am using
"Page.RegisterHiddenField("__EVENTTARGET", "btnSubmit")" but it does
not seem to be working for me.

I have another User Control which uses this technique and works.
Can't think of what I am missing?

Page.RegisterHiddenField("__EVENTTARGET", btnSubmit.UniqueID)
 
J

John Smith

That worked thanx a lot

--
Thanx in Advance,

atr2000
Andrea Zani said:
John Smith said:
I am having a brain fart today....

How do you set a default button within a User Control? I am using
"Page.RegisterHiddenField("__EVENTTARGET", "btnSubmit")" but it does
not seem to be working for me.

I have another User Control which uses this technique and works.
Can't think of what I am missing?

Page.RegisterHiddenField("__EVENTTARGET", btnSubmit.UniqueID)

--
AZ [Microsoft - .NET MVP]
Mia Home page: http://ciclismo.sitiasp.it
Asp.Net community: http://www.aspitalia.com
Il mio blog: http://blogs.aspitalia.com/az
 

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