 |
|
ขอสอบถามหน่อยครับว่าถ้าต้องการให้หน้าหลัก Refresh หลังจากที่กด เพิ่มข้อมูล สำเร็จแล้ว ต้องการให้หน้าหลัก Refresh รบกวนท่านผู้รู้ช่วยแนะนำหน่อยครับ

form Main
Code (ASP)
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="frm_popup1.aspx.vb" Inherits="data001.frm_popup1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
$(function () {
$(".DateSelector").datepicker({
dateFormat: 'd-MM-yy',
changeMonth: true,
changeYear: true,
yearRange: '2010:2030'
});
});
</script>
<script type="text/javascript">
function OpenPopup(url) {
popup = window.open(url, "mypopup", "location=1,status=1,scrollbars=1,width=420,height=300");
popup.moveTo(0, 0);
}
function OpenPopup1(url) {
popup = window.open(url, "mypopup", "location=1,status=1,scrollbars=1,width=1024,height=600");
popup.moveTo(0, 0);
}
</script>
<script type="text/javascript">
var popUpObj;
function showModalPopUp() {
popUpObj = window.open("frm_popup2.aspx",
"ModalPopUp",
"toolbar=no," +
"scrollbars=yes," +
"location=no," +
"statusbar=no," +
"menubar=no," +
"resizable=no," +
"width=600," +
"height=450," +
"left = 30," +
"top=90"
);
popUpObj.focus();
}
function CheckLine() {
popUpObj = window.open("Frm_Check.aspx",
"ModalPopUp",
"toolbar=no," +
"scrollbars=yes," +
"location=no," +
"statusbar=yes," +
"menubar=no," +
"resizable=yes," +
"width=500," +
"height=800," +
"left = 900," +
"top=90"
);
popUpObj.focus();
}
function Button4_onclick() {
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<span style="text-align: right">
<input
id="Button4" onclick="showModalPopUp()" type="button"
value="เพิ่มรายการ" onclick="return Button4_onclick()"
style="background-color: #00FF00" /></span><br />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="num1" DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="None" Height="43px" style="font-size: small"
Width="16px">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:BoundField DataField="num1" HeaderText="num1" ReadOnly="True"
SortExpression="num1" />
<asp:BoundField DataField="num2" HeaderText="num2" SortExpression="num2" />
<asp:BoundField DataField="num3" HeaderText="num3" SortExpression="num3" />
</Columns>
<EditRowStyle BackColor="#7C6F57" />
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#E3EAEB" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F8FAFA" />
<SortedAscendingHeaderStyle BackColor="#246B61" />
<SortedDescendingCellStyle BackColor="#D4DFE1" />
<SortedDescendingHeaderStyle BackColor="#15524A" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ESD_001ConnectionString %>"
SelectCommand="SELECT * FROM [popup]"></asp:SqlDataSource>
<br />
</div>
</form>
</body>
</html>
Form Popup2
Code (ASP)
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="frm_popup2.aspx.vb" Inherits="da001.frm_popup2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server">
Name<br />
<asp:TextBox ID="TextBox1" runat="server" BackColor="#FFCC00" ForeColor="Black"></asp:TextBox>
<br />
Lastname<br />
<asp:TextBox ID="TextBox2" runat="server" BackColor="#FFCC00" ForeColor="Black"></asp:TextBox>
<br />
Age<br />
<asp:TextBox ID="TextBox3" runat="server" BackColor="#FFCC00" ForeColor="Black"></asp:TextBox>
<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
<br />
<asp:Button ID="Button1" runat="server" Text="Update" />
<br />
<br />
<br />
<br />
<br />
<br />
</asp:Panel>
</div>
</form>
</body>
</html>
Code (VB.NET)
Imports System.Data.SqlClient
Imports System.Data
Public Class frm_popup2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Try
If TextBox1.Text = "" And TextBox2.Text = "" And TextBox3.Text = "" Then
Label1.Text = "กรุณากรอบข้อมูลก่อนนะ"
End If
Dim objConn As SqlConnection
Dim strConnString As String
Dim strSQL As StringBuilder
Dim objCmd As SqlCommand
Dim intCount As Integer = 0
Dim _date As String = DateAndTime.Now
'*** Open Connection ***'
strConnString = "Data Source=ComD01-PC\E_001_SERVER;Initial Catalog=E_001;Persist Security Info=True;User ID=sa;Password=1234567890"
objConn = New SqlConnection
objConn.ConnectionString = strConnString
objConn.Open()
'*** Check Username exists ***'
strSQL = New StringBuilder
strSQL.Append(" SELECT COUNT(*) FROM popup ")
strSQL.Append(" WHERE num1 = @ID ")
objCmd = New SqlCommand(strSQL.ToString(), objConn)
objCmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = Me.TextBox1.Text
intCount = objCmd.ExecuteScalar()
If intCount >= 1 Then
Me.Label1.ForeColor = Drawing.Color.Red
Me.Label1.Text = "มีข้อมูลนี้ในระบบแล้ว"
Return
End If
'*** Insert New Member ***'
strSQL = New StringBuilder
strSQL.Append(" INSERT INTO popup ")
strSQL.Append(" (num1,num2,num3)")
strSQL.Append(" VALUES ")
strSQL.Append(" (@ID,@Name,@Area) ")
objCmd = New SqlCommand(strSQL.ToString(), objConn)
objCmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = TextBox1.Text
objCmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = TextBox2.Text
objCmd.Parameters.Add("@Area", SqlDbType.VarChar).Value = TextBox3.Text
objCmd.ExecuteNonQuery()
objConn.Close()
objConn = Nothing
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
Catch ex As Exception
End Try
End Sub
End Class
Tag : ASP, Web (ASP.NET)
|
ประวัติการแก้ไข 2016-11-26 22:41:12 2016-11-26 22:42:13
|
 |
 |
 |
 |
Date :
2016-11-26 22:38:10 |
By :
treesak113 |
View :
1123 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |