日期:2014-05-18  浏览次数:20387 次

兄弟门帮帮我啊,提交表单就出错了
function   landsaccount()   //会员登陆部分检测
{
if(document.form1.c_account.value== " ")
{
alert( "提示:请输入登陆帐号! ");
document.form1.c_account.focus();
return   false;
}
if(document.form1.c_pwd.value== " ")
{
alert( "提示:请输入登陆密码! ");
document.form1.c_pwd.focus();
return   false;
}
if(document.form1.c_code.value== " ")
{
alert( "提示:请输入验证码! ");
document.form1.c_code.focus();
return   false;
}
document.form1.action= "/landing.aspx ";
document.form1.submit();

}
上面是JS段
然后提交的页面为= "/landing.aspx      


结果一提交过去就显示如下信息


验证视图状态   MAC   失败。如果此应用程序由网络场或群集承载,请确保   <machineKey>   配置指定了相同的   validationKey   和验证算法。不能在群集中使用   AutoGenerate。  
说明:   执行当前   Web   请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。  

异常详细信息:   System.Web.HttpException:   验证视图状态   MAC   失败。如果此应用程序由网络场或群集承载,请确保   <machineKey>   配置指定了相同的   validationKey   和验证算法。不能在群集中使用   AutoGenerate。


请问哥们门这是啥原因啊

------解决方案--------------------
<script language= "javascript ">
function Pd()
{
if(document.getElementById( 'TextSclb ').value==0)
{alert( '请选择生产类别! '); return false;}

if(document.getElementById( 'TextCxlb ').value==0)
{alert( '请选择车型类别! ');return false;}

if(document.getElementById( 'TextJt ').value== " ")
{alert( '请填写所属集团! ');return false;}

if(document.getElementById( 'TextPp ').value== " ")
{alert( '请填写所属品牌! ');return false;}

if(document.getElementById( 'TextXl ').value== " ")
{alert( '请填写所属系列! ');return false;}

if(document.getElementById( 'TextXh ').value== " ")
{alert( '请填写具体型号! ');return false;}

if(document.getElementById( 'TextGy ').value== " ")
{alert( '请填写制造工艺! ');return false;}

return true;
}
</script>
------解决方案--------------------
web.config中加入
<pages enableEventValidation= "false " viewStateEncryptionMode= "Never "/>

这张页面的HTML中加 EnableViewStateMac= "false "
如: <%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "info.aspx.cs " EnableViewStateMac= "false " Inherits= "DBMonitoring_Sell_info " %>
------解决方案--------------------
在按钮里调用Pd()就可以了!

if(document.getElementById( '你的控件名 ').value== " ")

------解决方案--------------------
asp.net的runat= 'server ' 会对ViewStat进行MAC的加密,使得提交数据时只能对同一页面进行。在接收页加上 @ page EnableViewStateMac= "false " 就可以接收另一页上post回来的数据。
------解决方案--------------------
或者通过在Web.config里边添加

<pages enableEventValidation= "false " viewStateEncryptionMode = "Never " />