Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Converting" asp.net form to html form

i have an asp.net webform. the users enter data into the textboxes and i do OnClick="SubmitData" with a button:

now i would like to use jquery and make my form look much better and i do not know if i can keep the asp.net controls or whether i have to convert to html controls.

question do i need to convert

<asp:TextBox ID="section_c_issue_error_identified_byTextBox"  width="500" runat="server" 
                    />

to something like this:

<textarea name="comments" id="comments" rows="5" cols="60"></textarea>

and if so, how would i grab the user input from these new html textboxes?

can you tell me exactly how would i pass these values into my c# code?

like image 717
Alex Gordon Avatar asked May 03 '26 13:05

Alex Gordon


2 Answers

You don't need to convert anything as it gets converted to html anyway on clientside.

There are few ways to grab the value of the text box such as,

If the following is my textbox,

   <asp:TextBox ID="txtCountry" Width="500" runat="server" CssClass="countryText" />

I can use,

$('#<%= txtCountry.ClientID%>').val()

$('.countryText').val()
like image 182
MSI Avatar answered May 05 '26 02:05

MSI


You don't need to convert anything, simply adding the property clientID the type static

 ClientIDMode="Static"

That's warranted that the id asp component doesn't change the name of the id

<asp:TextBox ID="txtCountry" Width="500" runat="server" CssClass="countryText"  ClientIDMode="Static" />

$('#txtCountry').val();   
like image 34
Jorge Avatar answered May 05 '26 03:05

Jorge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!