以下是点击确定按钮之后,分别热行的aspx页面里面的javascript函数,和相应的cs页面的函数.
aspx页面.
function confirm()
{
var flag = true;
var flagtime = true;
if("" == document.all.item("txtTitle").value || "<>" == document.all.item("txtTitle").value)
{
alert("标题不能为空!");
document.all.item('divID1').style.display = "block";
document.all.item('divID2').style.display = "none";
document.all.item('divID3').style.display = "none";
document.all.item('txt').value = "1";
document.all.txtTitle.focus();
flag = false;
document.all.item("txtTitle").value = "";
}
//若标题没有填,则不进行是否选择了人员的测试
if(true == flag)
{
if(document.all.uctrlResive_LisBoxSendTo.length == 0
&& document.all.uctrlResive_LisBoxSecretTo.length == 0)
{
alert("你必须至少选择一个收件人或密送人!");
document.all.item('divID2').style.display = "block";
document.all.item('divID1').style.display = "none";
document.all.item('divID3').style.display = "none";
document.all.item('txt').value = "2";
flagtime = false
}
} document.all.item("uctrlResive_txtbox").value = "3";
<TD><BUTTON class="mybutton1" id="btnOK" onmouseover="this.className='mybutton2'" onclick="javascript:void(0);confirm();"
onmouseout="this.className='mybutton1'" type="button" runat="server">确定</BUTTON> 以下CS页面确定按钮对应该的函数.
private void btnOK_ServerClick(object sender, System.EventArgs e)
{
MsgCont msgobj = GetMsgObj();
if(msgobj.SendToID != null || msgobj.SecretTo != null)
{
if("2" == flag)
{
//调用数据访问层,再次发送信息
(new MsgObj()).InsertAgain(Request.Params["MessageID"].ToString(),msgobj,0);
}
//如果是发送新信息
else
{
(new MsgObj()).InsertMessage(msgobj,"发送",Convert.ToInt16(this.Empid));
}
Response.Redirect("MessageDo.aspx?flag=1");
}
}现在我遇到的问题是:在if(true=flag)和if(document.all.uctrlResive_LisBoxSendTo.length == 0
&& document.all.uctrlResive_LisBoxSecretTo.length == 0) 都成立的情况下.点击确定按钮仍然会执行
Response.Redirect("MessageDo.aspx?flag=1");而且alert("你必须至少选择一个收件人或密送人!");这句话也会执行,但是最后还是会执行Response.Redirect("MessageDo.aspx?flag=1");这个问题该怎么解决呢.请高手指点!拜谢!拜谢!
aspx页面.
function confirm()
{
var flag = true;
var flagtime = true;
if("" == document.all.item("txtTitle").value || "<>" == document.all.item("txtTitle").value)
{
alert("标题不能为空!");
document.all.item('divID1').style.display = "block";
document.all.item('divID2').style.display = "none";
document.all.item('divID3').style.display = "none";
document.all.item('txt').value = "1";
document.all.txtTitle.focus();
flag = false;
document.all.item("txtTitle").value = "";
}
//若标题没有填,则不进行是否选择了人员的测试
if(true == flag)
{
if(document.all.uctrlResive_LisBoxSendTo.length == 0
&& document.all.uctrlResive_LisBoxSecretTo.length == 0)
{
alert("你必须至少选择一个收件人或密送人!");
document.all.item('divID2').style.display = "block";
document.all.item('divID1').style.display = "none";
document.all.item('divID3').style.display = "none";
document.all.item('txt').value = "2";
flagtime = false
}
} document.all.item("uctrlResive_txtbox").value = "3";
<TD><BUTTON class="mybutton1" id="btnOK" onmouseover="this.className='mybutton2'" onclick="javascript:void(0);confirm();"
onmouseout="this.className='mybutton1'" type="button" runat="server">确定</BUTTON> 以下CS页面确定按钮对应该的函数.
private void btnOK_ServerClick(object sender, System.EventArgs e)
{
MsgCont msgobj = GetMsgObj();
if(msgobj.SendToID != null || msgobj.SecretTo != null)
{
if("2" == flag)
{
//调用数据访问层,再次发送信息
(new MsgObj()).InsertAgain(Request.Params["MessageID"].ToString(),msgobj,0);
}
//如果是发送新信息
else
{
(new MsgObj()).InsertMessage(msgobj,"发送",Convert.ToInt16(this.Empid));
}
Response.Redirect("MessageDo.aspx?flag=1");
}
}现在我遇到的问题是:在if(true=flag)和if(document.all.uctrlResive_LisBoxSendTo.length == 0
&& document.all.uctrlResive_LisBoxSecretTo.length == 0) 都成立的情况下.点击确定按钮仍然会执行
Response.Redirect("MessageDo.aspx?flag=1");而且alert("你必须至少选择一个收件人或密送人!");这句话也会执行,但是最后还是会执行Response.Redirect("MessageDo.aspx?flag=1");这个问题该怎么解决呢.请高手指点!拜谢!拜谢!
解决方案 »
- 菜鸟求助一个WinForm问题,请各位高手勿喷.
- .Net与SSL的一点问题,是否一定要先导入证书?
- 试过无数方法 至今纠结 问天下英雄 违反并发性: UpdateCommand 影响了预期 1 条记录中的 0 条。
- QQ功能救急,怎么在主窗体中让好友头像闪动?
- 垃圾回收问题
- 大侠们,我是新手,快帮帮我解决一下Seesion的问题!
- 请问这段代码什么意思?实例化接口?什么意思???晕....
- 写属性的问题?大家帮忙.
- 急,在数据库中取数据两个dropdownlist关联???
- 急,求在C#中使用RealOne的媒体播放功能
- Form验证为什么只对第一次登录时有效,登录过后,再次打开这个站点时,它不通过登录页就直接进去了.
- 一个dialog问题
Attriblue 可能写错了 你自己对着看看吧
btnOK.Attribute.Add("onclick","javascript:return 函数名");在btnOK_ServerClick方法里的Flag参数你是如何获取的?
onmouseout="this.className='mybutton1'" type="button" runat="server">确定</BUTTON>这是什么东西 JS 要有返回值 老大
flag参数是在page_Load里面有这一句话!
if(Request.Params["flag"]!= null)
{
flag = Request.Params["flag"].ToString();
}
onmouseout="this.className='mybutton1'" type="button" runat="server">确定</BUTTON>这一句不是Js里面的.是html里面的.是系统自动生成的.我是让大家看的清楚,才贴上去的.不好意思!
{
var flag = true;
var flagtime = true;
if("" == document.all.item("txtTitle").value || "<>" == document.all.item("txtTitle").value)
{
alert("标题不能为空!");
document.all.item('divID1').style.display = "block";
document.all.item('divID2').style.display = "none";
document.all.item('divID3').style.display = "none";
document.all.item('txt').value = "1";
document.all.txtTitle.focus();
flag = false;
document.all.item("txtTitle").value = "";
}
//若标题没有填,则不进行是否选择了人员的测试
if(true == flag)
{
if(document.all.uctrlResive_LisBoxSendTo.length == 0
&& document.all.uctrlResive_LisBoxSecretTo.length == 0)
{
alert("你必须至少选择一个收件人或密送人!");
return false;//////////////////////////
document.all.item('divID2').style.display = "block";
document.all.item('divID1').style.display = "none";
document.all.item('divID3').style.display = "none";
document.all.item('txt').value = "2";
flagtime = false
}
}
这样做也不行的.还是会执行Response.Redirect("MessageDo.aspx?flag=1");
不过谢谢了!