Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET阻止FormView在数据无效时切换模板_C#_Asp.net_Formview - Fatal编程技术网

C# ASP.NET阻止FormView在数据无效时切换模板

C# ASP.NET阻止FormView在数据无效时切换模板,c#,asp.net,formview,C#,Asp.net,Formview,我有一个FormView,当用户在InsertTemplate上时,如果InsertTemplate中的数据无效,我希望在用户单击Insert按钮后FormView保持在InsertTemplate上 我尝试在FormView中使用许多事件,但没有一个有效。 我能猜到的最接近的事件是FormView\u ItemInserting protected void OfferDataFormView_ItemInserting(object sender, FormViewInsertEventAr

我有一个FormView,当用户在InsertTemplate上时,如果InsertTemplate中的数据无效,我希望在用户单击Insert按钮后FormView保持在InsertTemplate上

我尝试在FormView中使用许多事件,但没有一个有效。 我能猜到的最接近的事件是FormView\u ItemInserting

protected void OfferDataFormView_ItemInserting(object sender, FormViewInsertEventArgs e)
{
    if (Page.IsValid == false)
    {
        e.Cancel = true;
    }
}

但在单击Insert按钮后,此代码甚至不会被触发。因此,我无法阻止FV将其模板从InsertTemplate更改为EditTemplate。

ASP.NET网络表单真的正在消亡吗?甚至没有一个人回复……一天过去了,但没有人回复,只被浏览了7次。。。。我可以看到人们对旧的ASP.NET WebForms失去了兴趣。。。。至少有人能评论一下我的问题来表示你的支持吗?表单上是否有字段验证程序控件?如果您这样做,并且绑定模型的状态为IsValue=false,则不会触发insert命令,因此不会触发ItemInserting事件。您是否在按钮单击事件中检查了Page.Is有效?