JS代码:
<script type="text/javascript">
function SubNews()
{
var validateSucc;
if (typeof(Page_ClientValidate) == 'function')
validateSucc = Page_ClientValidate();
if(validateSucc)
{
saving.style.visibility="visible";
cover.style.visibility="visible";
tableCover.height = window.screen.height;
return true;
}
return true;
}
function EndSub()
{
saving.style.visibility="hidden";
cover.style.visibility="hidden";
}
</script>
Html
<asp:ImageButton ID="ibtnPost" OnClick="ibtnPost_Click" runat="server" ImageUrl="images/jlygda_index_01.jpg" OnClientClick="return SubNews();" >
</asp:ImageButton>
<%--等待提示DIV--%><div id="saving" style="z-index: 10; left: 130px; visibility: hidden; position: absolute;
top: 800px">
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td width="30%">
</td>
<td bgcolor="#acd0f0">
<table height="70" cellspacing="2" cellpadding="0" width="100%" border="0">
<tr>
<td align="center" bgcolor="#eeeeee">
正在保存视频, 请稍候...</td>
</tr>
</table>
</td>
<td width="30%">
</td>
</tr>
</table>
</div>
<div id="cover" style="z-index: 9; left: 0px; visibility: hidden; position: absolute;
top: 0px">
<table id="tableCover" cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td align="center">
<br>
</td>
</tr>
</table>
</div>
C#代码 /// <summary>
/// 提交
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ibtnPost_Click(object sender, ImageClickEventArgs e)
{
if (SaveData())
{
ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "StartupKey", "alert('添加视频成功');EndSub();", true);
Response.Redirect("VideoBackList.aspx?ChannelID=" + Convert.ToString(ViewState["ChannelID"]));
}
else
{
ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "StartupKey", "alert('添加视频失败');EndSub();", true);
}
}
问题:不显示提示DIV...应该如何修改?
<script type="text/javascript">
function SubNews()
{
var validateSucc;
if (typeof(Page_ClientValidate) == 'function')
validateSucc = Page_ClientValidate();
if(validateSucc)
{
saving.style.visibility="visible";
cover.style.visibility="visible";
tableCover.height = window.screen.height;
return true;
}
return true;
}
function EndSub()
{
saving.style.visibility="hidden";
cover.style.visibility="hidden";
}
</script>
Html
<asp:ImageButton ID="ibtnPost" OnClick="ibtnPost_Click" runat="server" ImageUrl="images/jlygda_index_01.jpg" OnClientClick="return SubNews();" >
</asp:ImageButton>
<%--等待提示DIV--%><div id="saving" style="z-index: 10; left: 130px; visibility: hidden; position: absolute;
top: 800px">
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td width="30%">
</td>
<td bgcolor="#acd0f0">
<table height="70" cellspacing="2" cellpadding="0" width="100%" border="0">
<tr>
<td align="center" bgcolor="#eeeeee">
正在保存视频, 请稍候...</td>
</tr>
</table>
</td>
<td width="30%">
</td>
</tr>
</table>
</div>
<div id="cover" style="z-index: 9; left: 0px; visibility: hidden; position: absolute;
top: 0px">
<table id="tableCover" cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td align="center">
<br>
</td>
</tr>
</table>
</div>
C#代码 /// <summary>
/// 提交
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ibtnPost_Click(object sender, ImageClickEventArgs e)
{
if (SaveData())
{
ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "StartupKey", "alert('添加视频成功');EndSub();", true);
Response.Redirect("VideoBackList.aspx?ChannelID=" + Convert.ToString(ViewState["ChannelID"]));
}
else
{
ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "StartupKey", "alert('添加视频失败');EndSub();", true);
}
}
问题:不显示提示DIV...应该如何修改?
ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "StartupKey", "alert('添加视频成功');EndSub();", true);
Response.Redirect("VideoBackList.aspx?ChannelID=" + Convert.ToString(ViewState["ChannelID"]));这样第一句还没执行完,已经跳到VideoBackList.aspx页面了!!
嗯..我也发现了...一会儿改一下...我现在想问的是...为什么我的OnClientClick事件没有起效?(没有提示信息的显示)
那我应该怎么做?<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true"><asp:ImageButton ID="ibtnPost" OnClick="ibtnPost_Click" runat="server" ImageUrl="images/jlygda_index_01.jpg" OnClientClick="return SubNews();" >
</asp:ImageButton>
</cc1:ToolkitScriptManager>这样?还是?
返回true就是要回发的,页面刷新了,怎么可能有效果呢??
返回false,才会有效果哦!!
function SubNews()
{
var validateSucc;
if (typeof(Page_ClientValidate) == 'function')
validateSucc = Page_ClientValidate();
if(validateSucc)
{
saving.style.visibility="visible";
cover.style.visibility="visible";
tableCover.height = window.screen.height;
return true;
}
else
{
return false; //没有验证通过时,那么就返回false;这样就不会再进行OnClick事件了。
} }
http://topic.csdn.net/u/20100308/09/7715bfc6-75db-46fa-a425-78bc34c65ded.html
用你提供的方法 FileUpload控件对象为空..无法正常上传文件