2

日付ピッカーからセッションを開催するにはどうすればよいですか?

すべてのテキストボックスについて、次を使用して保持します。

 Session["location"] = DropDownList1.SelectedItem.Text;
 Session["time"] = DropDownList2.SelectedItem.Text;
 Session["day"] = DropDownList3.SelectedItem.Text;  
 Session["IsChauffeurUsed"] = DropDownList4.SelectedItem.Text;

しかし、テキストボックスの日付ピッカーの場合、コードを書くとき

 Session["date"] = datepicker.Text;

エラーが発生します。現在のコンテキストは存在しません。日付ピッカーのテキストボックスは次のとおりです。

<div class="demo"><p>Date: <input type="text" id="datepicker"></p></div>

あなたが助けることができることを願っています。

ありがとう。

4

1 に答える 1

2

属性を設定runat=serverして、htmlタグをHtmlサーバーコントロールに変換します。

<input type="text" runat="server" id="datepicker">

value現在はASP.NETWebサーバーコントロールであるため、属性を使用します。

Session["date"] = datepicker.Value;

編集:これは私の側で完全に機能します。

<head runat="server">
    <title></title>
    <link rel="Stylesheet" type="text/css" href="http://code.jquery.com/ui/jquery-ui-git.css" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#datePicker").datepicker();
            $("#<%=TextBox1.ClientID %>").datepicker();
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="text" id="datePicker" runat="server" />
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
于 2012-08-29T03:13:23.123 に答える