Post by Goborijung at 2019-10-07 13:56:10 | ID: 150
<asp:DropDownList ID="ddSystem" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddSystem_SelectedIndexChanged"> <asp:ListItem>MDS</asp:ListItem> <asp:ListItem>PTS</asp:ListItem> <asp:ListItem>GSS</asp:ListItem> </asp:DropDownList>
Post by Goborijung at 2019-10-15 15:21:31 | ID: 157
Sub ExportToExcel()
Dim errorCheck As Integer = 0
Dim popupscript As String = ""
If dgvUserRequest.Rows.Count > 0 Then
Try
Response.ClearContent()
Response.Buffer = True
Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", "userRequest.xls"))
Response.ContentEncoding = Encoding.UTF8
Response.ContentType = "application/ms-excel"
' Dim sw As New stringwriter()
Dim tw As New IO.StringWriter()
Dim htw As New HtmlTextWriter(tw)
dgvUserRequest.RenderControl(htw)
Response.Write(tw.ToString())
Response.[End]()
Catch ex As Exception
errorCheck = 1
End Try
Else
errorCheck = 1
End If
If errorCheck = 1 Then
'a pop up error messege feature
popupscript = "<script language='javascript'>" + "alert(" + Chr(34) + "There was an error in exporting to exel, please make sure there is a grid to export!" + Chr(34) + ");</script>"
End If
End SubPost by Goborijung at 2019-10-10 11:55:34 | ID: 152
Sub ExportToExcel()
If DGV_userReport.Rows.Count > 0 Then
Try
DGV_userReport.Columns(0).Visible = False
Response.ClearContent()
Response.Buffer = True
Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", "UserRequiment.xls"))
Response.ContentEncoding = Encoding.UTF8
Response.ContentType = "application/ms-excel"
Dim sw As New StringWriter()
Dim htw As New HtmlTextWriter(sw)
DGV_userReport.RenderControl(htw)
Response.Write(sw.ToString())
Response.[End]()
Catch ex As Exception
Finally
DGV_userReport.Columns(0).Visible = True
End Try
End If
End SubPost by Goborijung at 2019-09-30 23:20:38 | ID: 135
>>> Form send.aspx
<form id="form1" runat="server" method="get" action="FormReceived.aspx">
ชื่อ - สกุล : <input type="text" name="FullName" />
<input type="submit" name="submit" value="GET" />
</form>
>>> Form get.aspx.vb
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim FullName = Request.QueryString("FullName")
If FullName Is Nothing Then
Response.RedirectPermanent("Default.aspx")
End If
If FullName.Trim() = "" Then
Response.RedirectPermanent("Default.aspx")
Else
Response.Write("ชื่อ - สกุล : " & FullName)
End If
End SubPost by Goborijung at 2019-09-30 23:33:49 | ID: 136
>>> Form send.aspx
<form id="form1" runat="server" method="post" action="FormReceived.aspx">
ชื่อ - สกุล :
<input type="text" name="FullName" />
<input type="submit" name="submit" value="POST" />
</form>
>>> Form get.aspx
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim FullName = Request.Form("FullName")
If FullName Is Nothing Then
Response.RedirectPermanent("Default.aspx")
End If
If FullName.Trim() = "" Then
Response.RedirectPermanent("Default.aspx")
Else
Response.Write("ชื่อ - สกุล : " & FullName)
End If
End SubPost by Goborijung at 2019-10-01 06:18:27 | ID: 137
<form action="FormReceived.aspx" method="post">
ชื่อ - สกุล :
<input type="text" name="FullName" />
<br /><input type="submit" name="submit" value="POST" />
<input type="submit" name="submit2" value="GET" formmethod="get" formaction="FormReceived.aspx" />
</form>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim FullName = Page.Request.Form("FullName")
If FullName Is Nothing Then
Response.RedirectPermanent("index.html")
End If
If FullName.Trim() = "" Then
Response.RedirectPermanent("index.html")
Else
Response.Write("ชื่อ - สกุล : " & FullName)
End If
End SubPost by Goborijung at 2019-10-08 14:43:19 | ID: 151
Imports System.Data.SqlClient
Imports System.Security.Cryptography
'** Function MD5 **'
Private Function md5(sPassword As String)
Dim x As New System.Security.Cryptography.MD5CryptoServiceProvider()
Dim bs As Byte() = System.Text.Encoding.UTF8.GetBytes(sPassword)
bs = x.ComputeHash(bs)
Dim s As New System.Text.StringBuilder()
For Each b As Byte In bs
s.Append(b.ToString("x2").ToLower())
Next
Return s.ToString()
End FunctionPost by Goborijung at 2019-10-15 14:04:10 | ID: 156
<asp:GridView ID="dgv1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="OID" HeaderText="OID" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:TemplateField HeaderText="Img" SortExpression="Image">
<ItemTemplate>
<a target="_blank" href="<%# Eval("Image") %>">
<asp:Image ID="imgProb" runat="server" ImageUrl='<%# Eval("Image") %>' /></a>
</ItemTemplate>
<HeaderStyle Width="1%" />
<ItemStyle CssClass="td-img" />
</asp:TemplateField>
</Columns>
</asp:GridView>Post by Goborijung at 2019-10-28 11:15:27 | ID: 167
>> ASPX - ที่หน้า ASPX ให้ทำการเพิ่ม Columns :: CommandField > Select - Add Action :: SelectedIndexChanged แล้วทำการเพิ่มคำสั่งดังนี้ >> ASPX.VB Dim row As GridViewRow = dgvVocabulary.SelectedRow txtOID.Text = row.Cells.Item(0).Text
Post by Goborijung at 2019-10-24 13:41:14 | ID: 165
<asp:GridView ID="dgvSaleOrder" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField HeaderText="OrderQTY" DataField="ORDQTYPCS" SortExpression="ORDQTYPCS" DataFormatString="{0:N0}" />
</Columns>
</asp:GridView>