我想在执行一些代码后淡出和删除div.使用按钮的onclientclick属性时,此JQuery函数正常工作.但是,无法从c#调用它.
JS:
function Confirm()
{
$(".saved").fadeIn(500).fadeOut(500);
}
Run Code Online (Sandbox Code Playgroud)
C#:
protected void btnsave_click(object sender, Eventargs e)
{
//some code
upd.update();
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Confirm",
"<script type='text/javascript'>Confirm();</script>", true);
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<asp:updatepanel id="upd" runat="server" updatemode="conditional">
<triggers>
<asp:asyncpostbacktrigger controlid="btnsave" eventname="click"/>
</triggers>
<contenttemplate>
<div style="position:relative">
<span class="saved">Record Saved</span>
<asp:gridview....../>
</div>
<asp:button id="btnsave" runat="server" text="save" onclick="btnsave_click"/>
</contenttemplate>
</asp:updatepanel>
Run Code Online (Sandbox Code Playgroud)
CSS:
.saved
{
position:absolute;
background:green;
margin:0 auto;
width:100px;
height:30px;
visibility:hidden;
}
Run Code Online (Sandbox Code Playgroud)
C#
protected void btn_click(object sender, Eventargs e)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "Confirm();", true);
}
Run Code Online (Sandbox Code Playgroud)
<script>
function Confirm()
{
$(".saved").fadeIn(500).fadeOut(500);
}
</script>
Run Code Online (Sandbox Code Playgroud)
C#
protected void btn_click(object sender, Eventargs e)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "Confirm();", true);
}
Run Code Online (Sandbox Code Playgroud)
<script>
$(document).ready(function () {
function Confirm() {
$(".saved").fadeIn(500).fadeOut(500);
};
});
</script>
Run Code Online (Sandbox Code Playgroud)