开发者

Problem with HTML input in Asp.net Content page,

开发者_开发技巧 <input type="text" id="txt_Respondby"  />

I am using JQuery UI DateTimePicker in the input above. it works well.

  <script type="text/javascript">
        $(function () {
            $('#txt_Respondby').datetimepicker();
        });
  </script>

I have included the required JS and there is no problem with the calender

Since I want to get the value selected from the calender in server side. I changed the input to runat="server" When I tried to run it the calender wasn't popping out. How can I access in server side the value selected in the calender.


Give this a shot:

$("#<%=txt_Respondby.ClientID%>").datetimepicker();


Try this:

<script type="text/javascript">
        $(function () {
            $('input[id$=txt_Respondby]').datepicker();
        });
</script>

Is your page using a Master Page? If so, "ctl00_ContentPlaceHolder1_" will be appended to your ID's where the control has runat="server". Therefore if you look for id txt_RespondBy it won't find it because the Id is now ctl00_ContentPlaceHolder1_txt_RespondBy.


Since you changed it to a server control. The rendered page changed the name to something like content...txt_RespondBy... In order to fix the problem you either need to use a wildcard in your JQuery or if you are using ASP.Net 4.0 set the ClientID property to Static.


you can use

Request["name_of_your_field"]

or in you js

  $(function () {
        $('#<%= txt_SendAt.ClientID  %>').datetimepicker();
    });

this way you get the text box id on the javascript(when you add runat="server" the final id is not the one in your aspx file (an other fun stuff about webforms)


you don't have to put runat="server" to access data from text box

you can do it like this

Request.Form["txt_SendAt"].ToString();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜