每当添加updatepanel时,JQuery UI datepicker都不起作用 [英] JQuery UI datepicker is not working whenever adding the updatepanel
本文介绍了每当添加updatepanel时,JQuery UI datepicker都不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我将JQuery UI Datepicker添加到我生成的textBox控件时,它正在工作,但无论我添加一个UpdatePanel它都无法工作我不知道为什么......
Javascript:
Hi, when adding a JQuery UI Datepicker to my generated textBox control,it is working but whatever I am adding an UpdatePanel it is not working I dont know why...
Javascript:
<script type="text/javascript">
$(function () {
$(".myDates").datepicker();
});
</script>
HTML:
HTML:
<div id="myForm" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlUserName" runat="server">
<fieldset class="fieldset">
<legend class="legend">Product Info</legend>
<div id="textBoxGenerated" runat="server">
<asp:TextBox ID="txtseachUserName" runat="server" required="required" class="search autosuggest"></asp:TextBox>
<asp:Button ID="btnsearch" runat="server" Text="Search" class="Buttom" OnClick="btnsearch_Click" /><br />
</div>
</fieldset>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
protected void btnsearch_Click(object sender, EventArgs e)
{
int number = Convert.ToInt32(txtseachUserName.Text);
string top = "";
int left = 0;
TextBox txt;
Table tb = new Table();
tb.ID = "tb1";
TableRow tr = new TableRow();
for (int i = 1; i <= number; i++)
{
Label lb = new Label();
lb.ID = "lbFname" + i.ToString();
lb.Text = "Date" + i + ":";
Literal l = new Literal();
l.Text = "<br/>";
txt = new TextBox();
txt.ID = "textBox" + i.ToString();//this will add the current number to textBox means textBox1, textBox2, textBox3 etc...
txt.Attributes.Add("runat", "server");
//txt.Attributes.Add("onkeyup", "SetButtonStatus(this,'btnSave')");
txt.CssClass = "myDates";
txt.Width = Unit.Pixel(240);
txt.Style.Add(HtmlTextWriterStyle.MarginTop, "5px");
txt.MaxLength = 1;
txt.EnableViewState = true;
txt.Style.Add(HtmlTextWriterStyle.Position, "relative");
//txt.Style[HtmlTextWriterStyle.Top] = top + "px";
txt.Style[HtmlTextWriterStyle.Left] = left + "px";
left += 0;
textBoxGenerated.Controls.Add(lb);
textBoxGenerated.Controls.Add(txt);
textBoxGenerated.Controls.Add(l);
}
可以有人帮忙!
can someone help!
推荐答案
(function(){
(function () {
(。myDates)。datepicker();
});
< / script >
(".myDates").datepicker(); }); </script>
HTML:
HTML:
<div id="myForm" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlUserName" runat="server">
<fieldset class="fieldset">
<legend class="legend">Product Info</legend>
<div id="textBoxGenerated" runat="server">
<asp:TextBox ID="txtseachUserName" runat="server" required="required" class="search autosuggest"></asp:TextBox>
<asp:Button ID="btnsearch" runat="server" Text="Search" class="Buttom" OnClick="btnsearch_Click" /><br />
</div>
</fieldset>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
protected void btnsearch_Click(object sender, EventArgs e)
{
int number = Convert.ToInt32(txtseachUserName.Text);
string top = "";
int left = 0;
TextBox txt;
Table tb = new Table();
tb.ID = "tb1";
TableRow tr = new TableRow();
for (int i = 1; i <= number; i++)
{
Label lb = new Label();
lb.ID = "lbFname" + i.ToString();
lb.Text = "Date" + i + ":";
Literal l = new Literal();
l.Text = "<br/>";
txt = new TextBox();
txt.ID = "textBox" + i.ToString();//this will add the current number to textBox means textBox1, textBox2, textBox3 etc...
txt.Attributes.Add("runat", "server");
//txt.Attributes.Add("onkeyup", "SetButtonStatus(this,'btnSave')");
txt.CssClass = "myDates";
txt.Width = Unit.Pixel(240);
txt.Style.Add(HtmlTextWriterStyle.MarginTop, "5px");
txt.MaxLength = 1;
txt.EnableViewState = true;
txt.Style.Add(HtmlTextWriterStyle.Position, "relative");
//txt.Style[HtmlTextWriterStyle.Top] = top + "px";
txt.Style[HtmlTextWriterStyle.Left] = left + "px";
left += 0;
textBoxGenerated.Controls.Add(lb);
textBoxGenerated.Controls.Add(txt);
textBoxGenerated.Controls.Add(l);
}
可以有人帮忙!
can someone help!
看到:在ASP.NET UpdatePanel中使用jQuery 并尝试...
这篇关于每当添加updatepanel时,JQuery UI datepicker都不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文