1) document.forms[0].submit('test') is an invalid syntax.. If you are looking
to send some additional value to server code, one common method is to use a
HTML Hidden Control or a TextBox Webcontrol with size 0.. In the code behind,
you could access the hidden control like Request.Form["HiddenCtrlName"]
.ToString();
2) document.SomeFormName.submit(); is a valid syntax.
I have a control that I want to act like a button. I cannot assume that the
containing page has a hidden control. I'm looking for a way to get the
client-side OnClick event to cause the server-side control event to fire.
Paul
> 1) document.forms[0].submit('test') is an invalid syntax.. If you are
> looking
[quoted text clipped - 22 lines]
>>
>> Paul
Sreejith Ram - 17 Oct 2005 20:28 GMT
2) " to get the control's containing form name "
One way i could think of is, you could get the parent control recursivly
until the parentElement.tagName == 'FORM'
I m writing below code on the fly... havent tested.. but hope it gives an
idea..
<script>
notFound = false;
ParentElem = document.getElementById("bttonName").parentElement;
while(notFound == false)
{
if(ParentElem.tagName == 'FORM')
{
//Now ParentElem is the FORM containing the control
// you my exit the loop and call ParentElem.Submit();
document.writeln(ParentElem.id);
notFound = true;
}
else
ParentElem = ParentElem.parentElement;
}
</script>
this should work, but you will be able to come up with a more efficient
recursive script for the same.. probably you will find a sample in
blogs/sites
1) not sure i have understood the requirement... When you say " I have a
control that I want to act like a button" , is that a webcontrol or a user
control?.. if user control, you could still have a hidden control next to the
button/image/link you are expecting the user to click..
> I have a control that I want to act like a button. I cannot assume that the
> containing page has a hidden control. I'm looking for a way to get the
[quoted text clipped - 28 lines]
> >>
> >> Paul