Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

getting info out of a form's submit method

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PJ6 - 17 Oct 2005 15:10 GMT
When I have client-side script like this -

   document.forms[0].submit('test')

how do I access, from server-side code, the value I put in the submit
method?

Also, is it possible to get the control's containing form name so I can
emite script like this -

   document.SomeFormName.submit('test')

so I don't have to assume it's in forms[0]?

Paul
Sreejith Ram - 17 Oct 2005 16:16 GMT
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.

> When I have client-side script like this -
>
[quoted text clipped - 11 lines]
>
> Paul
PJ6 - 17 Oct 2005 18:45 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.