私はフォームを使ってデータを入力する単純なMVCアプリケーションを作成しています。フォームを送信した後、特定の条件がfalse
の場合は別のページを表示します。 条件がfalseの場合はReturnToAction("Form");
を実行しても問題なく動作しますが、条件が成立した場合はRedirectToAction("MyPage");
フォーム提出に関連するアクションが実行されていてもフォームが表示されます。 私は何が欠けていますか?あなたが同じフォームを表示したい場合はasp.net mvc redirecttoactionは別のページを表示していません
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Form</title>
</head>
<body>
<form runat="server" method="post">
<ext:ResourceManager runat="server" />
<ext:Viewport runat="server" Layout="CenterLayout">
<Items>
<ext:FormPanel runat="server" id="Form" Url="/Home/CheckCondition"
Width="500"
Height="500"
Layout="CenterLayout"
>
<Items>
<ext:Window ID="Window1"
runat="server"
Closable="false"
Resizable="false"
Height="200"
Icon="Lock"
Title="Dashboard Login"
Draggable="false"
Width="350"
Modal="true"
BodyPadding="5"
Layout="FormLayout"
>
<Items>
<ext:TextField ID="txtUsername"
runat="server"
FieldLabel="Username"
AllowBlank="false"
BlankText="Your username is required."
Text="Demo" />
<ext:TextField ID="txtPassword"
runat="server"
InputType="Password"
FieldLabel="Password"
AllowBlank="false"
BlankText="Your password is required."
Text="Demo" />
</Items>
<Buttons>
<ext:Button ID="btnLogin" runat="server" Text="Login" Icon="Accept">
<Listeners>
<Click Handler="
if (!#{txtUsername}.validate() || !#{txtPassword}.validate()) {
Ext.Msg.alert('Error','The Username and Password fields are both required');
// return false to prevent the btnLogin_Click Ajax Click event from firing.
return false;
} else {
#{Form}.submit();
}" />
</Listeners>
</ext:Button>
</Buttons>
</ext:Window>
</Items>
</ext:FormPanel>
</Items>
</ext:Viewport>
</form>
</body>
</html>
コードブロックを置くことができますか、それは何が起こっているかを視覚化することはできますか? –
は返されますRedirectToAction – Steve