how to assign value to hidden field?

Posted by Vforvijay under ASP.NET on 5/24/2011 | Points: 10 | Views : 7836 | Status : [Member] | Replies : 3
hi..in my page am using grid view In gridview i used one text box and ajax calender,when the user choose the date it will be stored in the text box...
i need to store the date value also in hidden field ..how can i achieve this....




Responses

Posted by: Susanthampy on: 5/24/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,,,

Refer this link,,,,

http://msdn.microsoft.com/en-us/library/w100c6hw.aspx

Regards,
Susan

Vforvijay, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 5/25/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Vijay,
You can handle it using the client side event handler of ajax calendar extender

<asp:TextBox ID="TextBox122" runat="server"></asp:TextBox>

<asp:CalendarExtender TargetControlID="TextBox122" ID="CalendarExtender1" OnClientDateSelectionChanged="DateChanged" runat="server">
</asp:CalendarExtender>

lets say there exist a hidden field
<asp:HiddenField ID="myhdndate" runat="server" />

and finally description of DateChanged in script
<script type="text/javascript" language="javascript">

function DateChanged(sender, eventargs) {
document.getElementById("myhdndate").value = sender._selectedDate;
}
</script>


@Susan
Please read the post before replying :) , as i could see a lot like this (out of the context links have been posted).


Thanks,
Debata

Vforvijay, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prafullshrivastava on: 5/25/2011 [Member] Starter | Points: 25

Up
0
Down
Write this function in java script:

function checkDateDOB(sender, selectedDate)
{

var formattedDate = sender.formatDate(selectedDate, "M/d/yyyy");
document.getElementById('hiddenDOB').value=formattedDate
}

and call this function from aspx page:

(from your calender control)


<asp:CC1 TargetControlID="txtDOB" ID="CC1DOB" OnClientDateSelectionChanged="checkDateDOB" runat="server">


hear hiddenDOB is your hidden control.

Pshrivastava

Vforvijay, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response