我在做网页的时候有一个功能就是点一个按钮的时候有两个触发事件,它的效果是原来显示的现在影藏,影藏的那个就显示,可是我在点击后居然在几秒后又执行了二次操作,这个是怎么回事,求大神帮忙,下面是代码
<h2 class="title">
<asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>
<table width="100%">
<tr>
<td id="tb_1" style="width: 55%">
<asp:Literal ID="lDescriptionBrief" runat="server" />
</td>
<td id="tb_4" style="width:55%; display:none">
<asp:TextBox ID="txtDescriptionBrief" runat="server" Width="48%" MaxLength="500"
Height="35px" Style="font-size: 12px;" />
</td>
<td id="tb_2" style="width:25%">
<asp:HyperLink ID="HyperLink1" runat="server" />
<b style="font-size: 15px; padding: 12px">iGuide Catalogue #<%= Request["ItemID"] %></b>
</td>
<td id="tb_3" style="width: 20%">
<asp:PlaceHolder ID="phView" runat="server">
<asp:Button ID="ibEdit" runat="server" CssClass="edit-icon" OnClick="Edit" OnClientClick="Edit()" Style="padding: 0;
float: right; margin-top: 5px;" />
</asp:PlaceHolder>
<asp:PlaceHolder ID="phEdit" runat="server" Visible="false">
<asp:RequiredFieldValidator ID="rfvDescriptionBrief" runat="server" Display="Static"
ValidationGroup="vg" ErrorMessage="DescriptionBrief is required." ControlToValidate="txtDescriptionBrief"
Text="*" />
<asp:Button CssClass="save icon-butt" ID="btnSave" runat="server" Text="Save" ValidationGroup="vg"
OnClick="Save" />
<asp:Button CssClass="cancel icon-butt" ID="btnCancel" runat="server" Text="Cancel"
OnClick="Cancel" />
<asp:Image ID="Image1" ImageUrl="~/images/loading2.gif" runat="server" CssClass="img-loading" />
</asp:PlaceHolder>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</h2>
<script type="text/javascript">
function Edit() {
var tb_1 = document.getElementById("tb_1");
var tb_4 = document.getElementById("tb_4"); tb_1.style.display = (tb_1.style.display == "none" ? "" : "none");
tb_4.style.display = (tb_4.style.display == "none" ? "" : "none"); return false;
}
</script>public partial class price_guide_uc_DescriptionBrief : System.Web.UI.UserControl
{
public event OnUpdatedEventDelegate Updated; protected void Page_Load(object sender, EventArgs e) {
Session["itemDescription"] = lDescriptionBrief.Text;
} protected void Save(object sender, EventArgs e)
{
lDescriptionBrief.Text = Utils.HtmlSanitizer.Sanitize(txtDescriptionBrief.Text);
if (Updated != null)
{
Updated();
}
Cancel(null, null);
}
protected void Cancel(object sender, EventArgs e)
{
phView.Visible = true;
phEdit.Visible = false;
} protected void Edit(object sender, EventArgs e)
{
phView.Visible = false;
phEdit.Visible = true;
txtDescriptionBrief.Text = lDescriptionBrief.Text;
} public string DescriptionBrief
{
set { lDescriptionBrief.Text = value; }
get { return lDescriptionBrief.Text; }
}
}
buttononclickonclentclickvisible
<h2 class="title">
<asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>
<table width="100%">
<tr>
<td id="tb_1" style="width: 55%">
<asp:Literal ID="lDescriptionBrief" runat="server" />
</td>
<td id="tb_4" style="width:55%; display:none">
<asp:TextBox ID="txtDescriptionBrief" runat="server" Width="48%" MaxLength="500"
Height="35px" Style="font-size: 12px;" />
</td>
<td id="tb_2" style="width:25%">
<asp:HyperLink ID="HyperLink1" runat="server" />
<b style="font-size: 15px; padding: 12px">iGuide Catalogue #<%= Request["ItemID"] %></b>
</td>
<td id="tb_3" style="width: 20%">
<asp:PlaceHolder ID="phView" runat="server">
<asp:Button ID="ibEdit" runat="server" CssClass="edit-icon" OnClick="Edit" OnClientClick="Edit()" Style="padding: 0;
float: right; margin-top: 5px;" />
</asp:PlaceHolder>
<asp:PlaceHolder ID="phEdit" runat="server" Visible="false">
<asp:RequiredFieldValidator ID="rfvDescriptionBrief" runat="server" Display="Static"
ValidationGroup="vg" ErrorMessage="DescriptionBrief is required." ControlToValidate="txtDescriptionBrief"
Text="*" />
<asp:Button CssClass="save icon-butt" ID="btnSave" runat="server" Text="Save" ValidationGroup="vg"
OnClick="Save" />
<asp:Button CssClass="cancel icon-butt" ID="btnCancel" runat="server" Text="Cancel"
OnClick="Cancel" />
<asp:Image ID="Image1" ImageUrl="~/images/loading2.gif" runat="server" CssClass="img-loading" />
</asp:PlaceHolder>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</h2>
<script type="text/javascript">
function Edit() {
var tb_1 = document.getElementById("tb_1");
var tb_4 = document.getElementById("tb_4"); tb_1.style.display = (tb_1.style.display == "none" ? "" : "none");
tb_4.style.display = (tb_4.style.display == "none" ? "" : "none"); return false;
}
</script>public partial class price_guide_uc_DescriptionBrief : System.Web.UI.UserControl
{
public event OnUpdatedEventDelegate Updated; protected void Page_Load(object sender, EventArgs e) {
Session["itemDescription"] = lDescriptionBrief.Text;
} protected void Save(object sender, EventArgs e)
{
lDescriptionBrief.Text = Utils.HtmlSanitizer.Sanitize(txtDescriptionBrief.Text);
if (Updated != null)
{
Updated();
}
Cancel(null, null);
}
protected void Cancel(object sender, EventArgs e)
{
phView.Visible = true;
phEdit.Visible = false;
} protected void Edit(object sender, EventArgs e)
{
phView.Visible = false;
phEdit.Visible = true;
txtDescriptionBrief.Text = lDescriptionBrief.Text;
} public string DescriptionBrief
{
set { lDescriptionBrief.Text = value; }
get { return lDescriptionBrief.Text; }
}
}
buttononclickonclentclickvisible
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货