How to get client current date and time in asp.net?

前端 未结 6 1835
梦如初夏
梦如初夏 2021-01-07 02:52

I have a hidden field in my master page. And I set the current date and time as a value in that \"hiddenfield\" using Javascript. I am unable to get this hidden field value

6条回答
  •  时光取名叫无心
    2021-01-07 03:08

    modified code from This link:

    
    

    At this point i would concatenate all of the fields together and put them in an asp:HiddenField control so they can be read on the server. On the server, call Convert.ToDateTime() on the Text value of your HiddenField.

    if you don't use a masterpage you should try this.

    HiddenField hdnFieldValue = (HiddenField)PreviousPage.FindControl("hdnField");
    

    Updated:

    Put a hidden field on the page.

    
    

    in your javascript function

     var childHidden = document.getElementById('<%hidChild.ClientID%>');
     childHidden.value = window.opener.document.getElementById('text1').value;
    

    Now access this hidden control on the page load event.

    Response.Write(hidChild.Value); or Session["ParentVal"]=hidChild.Value;
    

提交回复
热议问题