|
-
Aug 3rd, 2005, 04:57 AM
#1
Thread Starter
Addicted Member
[resolved]document.Form
I need to get the value of a form element by using
document.Form1.txtName.value
I get an error when I use this on a web user control...
So I tried putting form tag in the html code still, it doesn't work dunno why, maybe its because I didn't put runat="server" but if I put this the page will return an error saying that it cannot allow two runat="server"
anyone?
Please help...
Thanks,
Jewel
Last edited by jewel; Aug 4th, 2005 at 12:25 AM.
xoxo
-
Aug 3rd, 2005, 05:09 AM
#2
Re: document.Form
Take a look at txtName's ID attribute when viewing the page in a browser. It has most likely changed when being rendered.
-
Aug 3rd, 2005, 05:16 AM
#3
Thread Starter
Addicted Member
-
Aug 3rd, 2005, 05:37 AM
#4
Re: document.Form
Open page in browser (run application) then in your browser, Edit > View Source.
-
Aug 3rd, 2005, 06:37 AM
#5
Frenzied Member
Re: document.Form
Either look in the HTML source as Mendhak says or you can access the client-side ID of a control from the ClientID property i.e. txtName.ClientID
DJ
If I have been helpful please rate my post. If I haven't tell me!
-
Aug 3rd, 2005, 07:46 AM
#6
Thread Starter
Addicted Member
Re: document.Form
hi, yes it changed it to MyControl1:sName because I embedded it as a web user control with name MyControl1, so I used this in the script
HTML Code:
alert (document.all["MyControl1:sName"].value );
however this will be a problem when I reuse the control under a different name...
any other suggestions?
Thanks,
Jewel
-
Aug 3rd, 2005, 07:53 AM
#7
Re: document.Form
Generate your javascript from codebehind and use controlname.ClientId in there.
-
Aug 3rd, 2005, 09:53 PM
#8
Thread Starter
Addicted Member
Re: document.Form
do you mean generate javascript from codebehind then use RegisterStartupScript? but this is not available for user control, right?
hmmm...
Thanks,
Jewel
-
Aug 3rd, 2005, 10:06 PM
#9
Thread Starter
Addicted Member
Re: document.Form
This works
VB Code:
Dim strScript As String = "alert (document.all['" & MyClass.ClientID & "_sName'].value );"
btnOk.Attributes.Add("onclick", strScript)
Thanks,
I wont put resolved yet coz i don't know if another problem would sneak in...
Last edited by jewel; Aug 3rd, 2005 at 10:36 PM.
xoxo
-
Aug 4th, 2005, 12:19 AM
#10
Re: document.Form
If another problem comes up, you can post a new thread.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|