英文:
Date Picker in Asp.net doesn't appear
问题
我创建了2个日期选择器,但只有1个在运行时显示日期表格。
<div class="form-group left">
<label for="invoicedate" class="label-title"> Invoice Date : </label>
<asp:TextBox ID="txtDate" runat="server" class="form-input" required="required" ReadOnly="true" placeholder="mm/dd/yyyy" OnClick="Datebtn_Click"></asp:TextBox>
</div>
<div class="form-group left">
<label for="shipmentdate" class="label-title"> Shipment Date : </label>
<asp:TextBox ID="textDate" runat="server" class="form-input" required="required" ReadOnly="true" placeholder="mm/dd/yyyy" OnClick="Addbtn_Click"></asp:TextBox>
</div>
代码部分:
protected void Datebtn_Click(object sender, EventArgs e)
{
string dt = Request.Form[txtDate.UniqueID];
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Selected Date:" + dt + "'); ", true);
}
protected void Addbtn_Click(object sender, EventArgs e)
{
string dt = Request.Form[txtDate.UniqueID];
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Selected Date:" + dt + "'); ", true);
}
脚本代码:
<script type="text/javascript">
$(function () {
$('[id*=txtDate]').datepicker({
changeMonth: true,
changeYear: true,
format: "dd/mm/yyyy",
language: "tr"
});
});
</script>
当我运行它时,没有显示任何错误。有人能帮助我吗?
英文:
I make 2 datepicker but only 1 show the table of date when I run it
<div class="form-group left">
<label for="invoicedate" class="label-title"> Invoice Date : </label>
<asp:TextBox ID="txtDate" runat="server" class="form-input" required="required" ReadOnly="true" placeholder="mm/dd/yyyy" OnClick="Datebtn_Click"></asp:TextBox>
</div>
<div class="form-group left">
<label for="shipmentdate" class="label-title"> Shipment Date : </label>
<asp:TextBox ID="textDate" runat="server" class="form-input" required="required" ReadOnly="true" placeholder="mm/dd/yyyy" OnClick="Addbtn_Click"></asp:TextBox>
</div>
The code behind
protected void Datebtn_Click(object sender, EventArgs e)
{
string dt = Request.Form[txtDate.UniqueID];
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Selected Date:" + dt + "'); ", true);
}
protected void Addbtn_Click(object sender, EventArgs e)
{
string dt = Request.Form[txtDate.UniqueID];
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Selected Date:" + dt + "'); ", true);
}
Script code
<script type="text/javascript">
$(function () {
$('[id*=txtDate]').datepicker({
changeMonth: true,
changeYear: true,
format: "dd/mm/yyyy",
language: "tr"
});
});
</script>
It doesn't show any error when I run it. Can anyone help me
答案1
得分: 0
因为您创建了两个具有不同Id的文本框,一个是"txtDate",另一个是"textDate"。
对于Addbtn_Click:id 应更改为:"textDate.UniqueID"。
脚本中只有txtDate。
在进行所有相应的修改之后,两者都应该能够正常工作。
英文:
Because you created two textboxes with different Ids, one with "txtDate" and another with "textDate".
For Addbtn_Click: id should be changed to: "textDate.UniqueID"
There is only txtDate in the script.
After all corresponding modifications are made, then both should be able to work.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论