Wednesday 15 May 2013

asp.net - No Form.Submit() function in VB.NET or C#? -


I have some problems with my code because I can not do it in VB.NET or C # because no form 1 is not I VB.NET or C # ???

  & lt; Script language = "javascript" & gt; Submit () function in Function valSubmit () {varMyReg = document.form1.lst Country. Option [document.form1.lstCountry.selectedIndex] .value; VarNewReg = varMyReg.substring (0, 3); Document.form1.hdnRegion.value = varNewReg; Document.form1.action = "http://now.eloqua.com/e/f2.aspx" document.form1.submit (); Back true; } & Lt; / Script & gt;  

Why is it or how can I do it in VB.NET or C #?

C # and VBnet server-side languages ​​are the client-side function of submitting a form in the browser , So you can not use C # or VBnet You have to use Javascript for this (though you can include JavaScript in your HTML using C # or VBnet).

  string js = @ "function valSubmit () {varMyReg = Document Form1.lstCountry.options [document.form1.lstCountry.selectedIndex] .value; varNewReg = varMyReg.substring (0, 3) ; Document.form1.hdnRegion.value = varNewReg; document.form1.action = 'Now http: // now .eloqua.com / E / f2.aspx' document.form1.submit (); back true;} "; RegisterStartupScript ("submitform", js);  

You can modify and modify the script according to your needs, especially to recognize ASP.NET control properly. For example, you can use it. Form. Client IDs to get the main form's ID on one page. To remove the client-script, you can use both (before the end of the page) and (at the beginning of the page)


No comments:

Post a Comment