I am working on an asp.net page where I am saving user input into my database using TextBox e.g ***<asp:TextBox ID="code" runat="server" Width="155px"></asp:TextBox>***
in this case I'm getting the ID of the TextBox as "code" so i can capture the values from that TextBox. Now i have a jQuery texbox <input type="text" id="date" required="required"/> where "date" is jQuery function ID. Which attribute or ID should i use to capture the user input and save them into my database using this <input type="text" id="date" required="required"/> textbox..?
-
your question is not clear. Please provide your code and phrase it properlySameer– Sameer2017-07-10 13:38:49 +00:00Commented Jul 10, 2017 at 13:38
-
this is vague and uses confusing terminology. Post the relevant code please.ADyson– ADyson2017-07-10 13:39:33 +00:00Commented Jul 10, 2017 at 13:39
3 Answers
you can change your plain textbox to asp textbox
<asp:TextBox Id="date" runat="server" required="required" />
if not than you can get values of plain Html elements in code behind.
- Write a function to set the value of "date" textbox to a hidden field
- Than capture the value of hiddenfield in your code behind
Hope this helps
Comments
Why not simply turn that field into a asp.net control as well?
Would be:
<asp:TextBox Id="date" runat="server" required="required" />
It will be rendered as a input type="text" to the browser anyway and should work just fine.
In order to find the control (since ASP.NET sometimes have the odd interest in prefixing controls) you can just use $find in your script. Or, as someone pointed out, use class selectors (i.e assign a CssClass attribute to your TextBox) and use that as selector in your jQuery code.
That way the date value will be available both to server side operations and client side.