1

I am working with asp.net controls(textboxes), but only for the calendar control I am using jquery code(because it has a good UI) that has html <input type="text" id="datepicker">

Now, I want to insert the value of this input field into the database. With asp.net controls,it is easily possible using cmd.Parameters.AddWithValue("@MemberId", txtMemberId.Text); But I am stuck with the html input control, Please help me out. Thank you.

Sumedha Vangury
  • 643
  • 2
  • 17
  • 43

2 Answers2

2

You can use runat = "server" for your HTML control or you can alternatively use a hiddenfield to store the selected data and this hidden field value can be accessed in your code. You'll have to assign the value of datepicker.text to the hidden field through javascript.

You can access the hidden field value in code as hdnDate.Value

The link here will help you understand when to use runat="server" on normal HTML controls.

Community
  • 1
  • 1
Dennis R
  • 3,195
  • 1
  • 19
  • 24
1

You should be able to access the control by doing this:

<input type="text" id="datepicker" runat = "server">
logixologist
  • 3,694
  • 4
  • 28
  • 46
  • Thank you, but then how should I insert this value into the database? should I use the id and write `insert into table values('"+datepicker.text+"')` where datepicker is the id of the input control? – Sumedha Vangury Jul 25 '14 at 18:01
  • I would assume you use datePicker.value. Once you do runat = Server it will show up in intellesense. – logixologist Jul 25 '14 at 18:04
  • but now I have another problem, when I combine jquery code with twitter bootstrap the calendar does not show up.How should I solve this.Please help – Sumedha Vangury Jul 26 '14 at 05:17