尝试使用react js在Asp.net mvc中转换asp.net登录页面

时间:2018-04-17 05:49:05

标签: asp.net-mvc reactjs

我非常想对js做出反应,我正在尝试使用react js在Asp.net mvc中转换asp.net登录页面。 的Login.aspx

<div class="content">

                                    <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="material-icons">account_circle</i>
                                        </span>
                                      <asp:TextBox ID="txtUserName" class="form-control" placeholder="Personal Number..."  runat="server" ></asp:TextBox>

                                    </div>

                                    <div class="input-group">
                                        <span class="input-group-addon">
                                            <i class="material-icons">lock_outline</i>
                                        </span>
                                        <asp:TextBox ID="txtPswd" class="form-control" placeholder="Password..." runat ="server" TextMode ="Password"  ></asp:TextBox>
                                    </div>

                                    <div class="input-group">
                                        <asp:Label ID="lblError"  runat ="server" Visible="false" ></asp:Label>
                                    </div>
                                </div>
<div class="footer text-center">
                                       <asp:Button class="btn btn-primary" ID="btn_Login" runat="server" Text="Login" OnClick="btn_Login_Click"></asp:Button>
                                    <a href="Home.aspx" class="btn btn-primary">Back</a>
                                </div>  

Login.aspx.cs

protected void btn_Login_Click(object sender, EventArgs e)
    {
        Service1 objAd = new Service1();
        dynamic newResult = string.Empty;

        try
        {
            newResult = objAd.IsAuthenticatedWithMessage("mbs", txtUserName.Text.ToString(), txtPswd.Text.ToString());
            if (newResult.Equals("Authenticated"))
            {
                createSessionForUser(txtUserName.Text.ToString());
                lblError.Visible = false;
            }
            else
            {
                lblError.Visible = true;
                lblError.Text = "Invalid Username and Password..";
            }
        }
        catch (Exception ex)
        {
            Response.Redirect("ErrorPage.aspx");
        }
    }

如何在反应js和asp.net mvc中转换这个结构任何想法都会受到赞赏。我已经在visual studio中完成了与asp.net mvc的反应js的设置。

0 个答案:

没有答案