สวัสดีครับ ขอความข่วยเหลือหน่อยครับ พอดีผมจะทำให้เป็น Datetimenow แต่เมื่อใช้กับ Textbox ที่มี Type เป็น type="date"
TextBox2.Text = d.ToString("dd-MM-yyyy ");
เปลี่ยนเป็น
TextBox2.Text = d.ToString("yyyy-MM-dd ");
input type date value จะมี format เป็น YYYY-MM-DD
ส่วนการแสดงผล จะอ้างอิง format ของ เครื่องคอมนั้นๆ
แต่เวลากำหนด หรืออ่านจาก object ต้องใช้ 2009-01-08
Date :
2019-01-08 11:50:39
By :
Chaidhanan
เอาโค๊ดมาลงไว้ จะแก้ง่ายกว่า เพราะเขียนให้ดู มันก็เหมือนๆ กับตัวอย่างต่างๆ ที่อยู่บนเวปนั่นแหล่ะ
เอาโค๊ดมาลงจะได้รู้ว่าผิดตรงไหน
Date :
2019-01-08 14:39:45
By :
Chaidhanan
Code (C#)
Code C#
Code (C#)
[cs]using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Text;
using System.Globalization;
using System.Threading;
namespace Test
{
public partial class _Default : Page
{
SqlConnection conn = new SqlConnection("Data Source=ARTEMIS\\SQL2014;Initial Catalog=SvlITDB;User ID=it;Password=Tigers1234");
protected void Page_Load(object sender, EventArgs e)
{
DateTime d = DateTime.Now.Date;
TextBox3.Text = d.ToString("yyyy-MM-dd");
//DateTime daValues1 = DateTime.Now;
//string MyDt = daValues1.ToString("'HH:mm:ss'");
//TextBox3.Text = MyDt;
DateTime daValues = DateTime.Now;
Random r = new Random();
int num = r.Next();
string MyDt2 = daValues.ToString("yyMM-mmss");
this.TextBox6.Text = num.ToString("'IT','" + MyDt2 + "'");
if (Session["DeptName"] != null && Session["Tel"] != null) {
Label12.Text = Session["DeptName"].ToString();
Label13.Text = Session["Tel"].ToString();
}
}
#region Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
if (DropDownList3.Text == "0")
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Myscript", "alert(' . . . . . . . . . <กรุณาเลือก >> ประเภทของปัญหา << ด้วยค่ะ !!! > . . . . . . . . . ')", true);
}
else if (TextBox1.Text == "")
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Myscript", "alert(' . . . . . . . . . <กรุณากรอก >> หัวข้อ << ด้วยค่ะ !!! > . . . . . . . . . ')", true);
}
else if (Request.Form["Message"] == "" )
{
string scriptText = "alert(' . . . . . . . . . <กรุณากรอก >> รายละเอียด << ด้วยค่ะ !!! > . . . . . . . . . ');";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (TextBox3.Text == "")
{
string scriptText = "alert(' . . . . . . . . . <กรุณาใส่ >> วันที่ << ด้วยค่ะ !!! > . . . . . . . . . ');";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (TextBox5.Text == "")
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Myscript", "alert(' . . . . . . . . . <กรุณากรอก >> ชื่อผู้แจ้งปัญหา << ด้วยค่ะ !! > . . . . . . . . . ')", true);
}
else {
if (Session["DeptName"].ToString() == "Human Resources")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',5,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (Session["DeptName"].ToString() == "Accounting")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',2,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (Session["DeptName"].ToString() == "Purchase")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',9,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (Session["DeptName"].ToString() == "Store")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',11,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (Session["DeptName"].ToString() == "Quarrying")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',13,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (Session["DeptName"].ToString() == "Ministry")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',14,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (Session["DeptName"].ToString() == "Rubber")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',15,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (Session["DeptName"].ToString() == "Construction")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',16,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (Session["DeptName"].ToString() == "Concrete")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',17,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (Session["DeptName"].ToString() == "Maintenance")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',19,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (Session["DeptName"].ToString() == "Sale")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',20,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (Session["DeptName"].ToString() == "Marketing")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',22,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (Session["DeptName"].ToString() == "Finance")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',23,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
else if (Session["DeptName"].ToString() == "PouringRubber")
{
conn.Open();
SqlCommand sqlcom = conn.CreateCommand();
sqlcom.CommandText = "INSERT INTO [dbo].[Case] ( [CaseName], [CaseDetail], [CaseDT], [CaseStatusKey], [Requester], [UsrKey], [CaseTypeKey],[CaseCode]) VALUES ( '" + TextBox1.Text + "','" + Request.Form["Message"] + "','" + TextBox3.Text + "',1,'" + TextBox5.Text + "',25,'" + DropDownList3.Text + "','" + TextBox6.Text + "')";
sqlcom.CommandType = CommandType.Text;
sqlcom.ExecuteNonQuery();
conn.Close();
string scriptText = "alert(' . . . . . . . . . <บันทึกการแจ้งปัญหาสำเร็จ > . . . . . . . . . '); window.location='" + Request.ApplicationPath + "RequestionShow.aspx'";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", scriptText, true);
}
}
}
#endregion
#region Button2_Click
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
TextBox5.Text = "";
DropDownList3.Text = "0";
}
protected void Button2_Click1(object sender, EventArgs e)
{
}
protected void Button3_Click(object sender, EventArgs e)
{
}
protected void TextBox6_TextChanged(object sender, EventArgs e)
{
}
protected void TextBox7_TextChanged(object sender, EventArgs e)
{
}
}
}
#endregion
####################################################################################################
Code ASP
Code (ASP)
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Test._Default" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet"/>
<link rel="stylesheet" href="css/animate.css"/>
<link rel="stylesheet" href="css/font-awesome.min.css"/>
<link rel="stylesheet" href="css/jquery.bxslider.css"/>
<link rel="stylesheet" type="text/css" href="css/normalize.css" />
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/set1.css" />
<link href="css/overwrite.css" rel="stylesheet"/>
<link href="css/style2.css" rel="stylesheet"/>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse.collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="Default.aspx"><span>
<img src="http://localhost:51924/img/IT1.gif" style="height: 65px; width: 70px; margin-top:-18px" /> Suvalee Company</span></a>
</div>
<div class="navbar-collapse collapse">
<div class="menu">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="Default.aspx">แจ้งปัญหา</a></li>
<li role="presentation"><a href="RequestionShow.aspx">แสดงปัญหาที่แจ้ง</a></li>
<li role="presentation"><a href="Login.aspx">ออกจากระบบ</a></li>
</ul>
</div>
</div>
</div>
</nav>
<br />
<br />
<p style="text-align:center; font-size:25px; color:black;">ระบบแจ้งปัญหาสารสนเทศ</p>
<p style="margin-left:390px ; font-size:25px">
<strong>
<asp:Label ID="Label11" runat="server" Text="แผนก : " Font-Size="18px" style="font-size: medium"></asp:Label>
</strong><span style="font-size: medium"><strong>
</strong></span><strong>
<asp:Label ID="Label12" runat="server" Font-Size="18px" Text="Label" style="font-size: medium"></asp:Label>
</strong><span style="font-size: medium"><strong> </strong></span><strong> <asp:Label ID="Label10" runat="server" Text="เบอร์โทรศัพท์ : " Font-Size="18px" style="font-size: medium"></asp:Label>
</strong> <strong><asp:Label ID="Label13" runat="server" Font-Size="18px" Text="Label" style="font-size: medium"></asp:Label>
</strong>
</p>
<div class="errorContainer" align="Center" >
<table align="Center" style="width: 34%; height: 230px;"> <tr>
<td style="height: 40px; width: 176px; text-align: right; font-size: medium;" class="text-justify" >
CODE </td>
<td style="height: 40px">
<asp:TextBox ID="TextBox6" runat="server" OnTextChanged="TextBox6_TextChanged" Width="200px" ReadOnly="true" Enabled="false" Font-Size="14px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="height: 17px; width: 176px; text-align: right; font-size: medium;">
ประเภทปัญหา </td>
<td style="height: 40px">
<asp:DropDownList ID="DropDownList3" runat="server" Font-Size="14px">
<asp:ListItem Value="0">===กรุณาเลือก===</asp:ListItem>
<asp:ListItem Value="1">Computer</asp:ListItem>
<asp:ListItem Value="2">Printer</asp:ListItem>
<asp:ListItem Value="3">Wireless</asp:ListItem>
<asp:ListItem Value="6">ระบบ Syteline</asp:ListItem>
<asp:ListItem Value="4">อื่นๆ</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 176px; height: 28px; text-align: right; font-size: medium;">
หัวข้อ </td>
<td style="height: 40px">
<asp:TextBox ID="TextBox1" runat="server" Font-Size="14px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 176px; height: 71px; text-align: right; font-size: medium;">
รายละเอียด </td>
<td style="height: 105px">
<textarea id="TextArea1" cols="35" name="Message" rows="4" ></textarea></td>
</tr>
<tr>
<td style="width: 176px; height: 27px; text-align: right; font-size: medium;">
วันที่แจ้งปัญหา </td>
<td style="height: 40px">
<asp:TextBox ID="TextBox3" runat="server" Font-Size="14px" type="date" name="party-time" Height="22px" ></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 176px; height: 34px; text-align: right; font-size: medium;">
ชื่อผู้แจ้งปัญหา </td>
<td style="height: 40px">
<asp:TextBox ID="TextBox5" runat="server" Font-Size="14px"></asp:TextBox>
</td>
</tr>
</table>
<br />
<asp:Button ID="Button1" runat="server" Text="บันทึก" OnClick="Button1_Click" align="center" />
<asp:Button ID="Button2" runat="server" Text="ยกเลิก" align="center" OnClick="Button2_Click1" />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
<footer>
</footer>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery-2.1.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script src="js/wow.min.js"></script>
<script src="js/jquery.easing.1.3.js"></script>
<script src="js/jquery.isotope.min.js"></script>
<script src="js/jquery.bxslider.min.js"></script>
<script type="text/javascript" src="js/fliplightbox.min.js"></script>
<script src="js/functions.js"></script>
<script type="text/javascript">$('.portfolio').flipLightBox()</script>
</asp:Content>
[/vb]
ประวัติการแก้ไข 2019-01-09 07:54:14 2019-01-09 08:41:00
Date :
2019-01-09 07:52:47
By :
HI
ผมก็ไม่ชำนาญวิธีการเขียนแบบนี้อะครับ มักจะกำหนดตัวแปรใส่ค่า ลงไปตรงๆใน VIEW
แบบใน view ผมจะให้มัน มี tag asp น้อยที่สุด (ติดมาจาก php 5555) และเขียน ตัวรับ request สำหรับเซฟแยก ไปอีกไฟล์ต่างหาก
ไม่ค่อยเขียน ปนกันแบบนี้
Code (C#)
public partial class _Default : Page
{
SqlConnection conn = new SqlConnection("Data Source=ARTEMIS\\SQL2014;Initial Catalog=SvlITDB;User ID=it;Password=Tigers1234");
protected void Page_Load(object sender, EventArgs e)
{
DateTime d = DateTime.Now.Date;
TextBox3.Text = d.ToString("yyyy-MM-dd"); // กำหนดตรงนี้ ผมไม่แน่ใจว่า เวลา request ส่งค่ามาเซฟ มันจะเอาค่าไปใส่หรือเปล่า ก็ลงลอง เซทค่าให้ textbox อื่นดู เพื่อจะเห็นความแตกต่างที่ชัดเจน ว่ามันมีผลกับการเซฟ หรือไม่
Code (C#)
<%
DateTime d = DateTime.Now.Date; // ผมชอบทำใน VIEW มากกว่า
%>
<script type="text/javascript">
$('.portfolio').flipLightBox();
$(document).ready(()=>{
$('#TextBox3').val(<%=d.toString("yyyy-MM-dd")?>);
});
</script>
Date :
2019-01-09 13:12:43
By :
Chaidhanan
+1 ได้คำสั่งเพิ่มเหมือนกัน ไม่ค่อยได้เขียนแบบนี้ เพราะขี้เกียจศึกษาเพื่ิมนั่นแหล่ะ เพราะมันใช้อย่างอื่นได้อยู่
Date :
2019-01-11 10:45:02
By :
Chaidhanan
Load balance : Server 01