PDA

View Full Version : ایجاد یک فرم login popup



arioban
سه شنبه 18 آبان 1395, 14:06 عصر
من یک فرم popup login نوشتم و همه چیز درست هست الا یک چیز دکمه ورود در فرم login کار نمیکنه و من نمی دونم چجوری باید حلش کنم
این هم کدهای که نوشتم
لطفا اگر کسی میدونه راهنماییم کنه
<%@ Page Language="C#‎‎‎‎" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<%@ Register Src="~/WebUserControl1.ascx" TagPrefix="uc1" TagName="WebUserControl1" %>


<!DOCTYPE html>


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>


<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>


<script>


$(function () {


$('#Button1').click(function () {


$('#popup').dialog({


title: "login control",
width: 350,
height: 200,
modal: true,
button: {
close: function () {
$(this).dialog('close');
}
}
});
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="popup" title="login form" style="display: none">
<uc1:WebUserControl1 runat="server" ID="WebUserControl1" />
</div>
<input id="Button1" type="button" value="click" />
</div>
</form>
</body>
</html>





<%@ Control Language="C#‎‎‎‎" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="WebApplication1.WebUserControl1" %><style type="text/css">
.auto-style1 {
width: 92px;
}


.auto-style2 {
width: 213px;
}


.auto-style3 {
width: 28%;
}
</style>
<table class="auto-style3">
<tr>
<td class="auto-style1">Username</td>
<td class="auto-style2">
<asp:TextBox ID="TextBox1" runat="server" ValidationGroup="v1" Width="160px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator" ForeColor="Red" ValidationGroup="v1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style1">Password</td>
<td class="auto-style2">
<asp:TextBox ID="TextBox2" runat="server" ValidationGroup="v1" Width="160px" TextMode="Password"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2" ErrorMessage="RequiredFieldValidator" ForeColor="Red" ValidationGroup="v1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style1">&nbsp;</td>
<td class="auto-style2">
<asp:Button ID="Button2" runat="server" Text="login" OnClick="Button2_Click" />
</td>
<td>&nbsp;</td>
</tr>
</table>




using System;using System.Collections.Generic;
using System.Linq;
using System.Web.UI;




namespace WebApplication1
{
public partial class WebUserControl1 : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{


}


protected void Button2_Click(object sender, EventArgs e)
{
string u1 = "username";
string p1 = "123456";
if (TextBox1.Text == "" & TextBox2.Text == "")
{
//ClientScript.RegisterStartupScript(this.GetType(), "alert", "لطفا نام کاربری و کلمه عبور را وارد نمایید");
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", "<script>alert('لطفا نام کاربری و کلمه عبور را وارد نمایید')</script>", false);
}
else if (TextBox1.Text == u1 & TextBox2.Text == p1)
{
Response.Redirect("https://www.google.com/?gws_rd=ssl");
}
else if (!(TextBox1.Text == u1) || (TextBox2.Text == p1))
{
//ClientScript.RegisterStartupScript(this.GetType(), "alert", "نام کاربری یا کلمه عبور اشتباه می باشد! ");
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", "<script>alert('نام کاربری یا کلمه عبور اشتباه می باشد!')</script>", false);
}
}
}
}