 |
|
ไม่เข้าใจมากๆครับ ว่าทำไม....ช่วยตอบด้วยนะครับ (ไม่รู้จิงๆครับ) ตั้ง Auto postback แล้วทำไมในตัวแปลถึงเป็นค่าว่างครับ |
|
 |
|
|
 |
 |
|
ผมว่าผมสั่ง postback อย่างเดียว โดยยังไม่ได้แฮนเดิลอีเว็นต์แหละ
|
 |
 |
 |
 |
Date :
2010-08-30 15:39:42 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แต่ว่า มันก็ต้องนำไปใช้ใน Method กำหนดค่าอีกนะครับ ไม่แน่ใจว่าถ้าทำเป็น sub แล้วจะให้งานในคลาสอื่นได้
|
 |
 |
 |
 |
Date :
2010-08-31 14:21:36 |
By :
accio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สำหรับ asp.net ค่ะ
ในกรณีใช้ตัวแปรนี้แบบ Postback ธรรมดา แต่ถ้าเป็น AJAX ก็ไม่จำเป็นต้องเก็บไว้ใน ViewState ค่ะ
Code (C#)
partial class .....
{
private string chkQ_Spacial
{
get
{
if(ViewState["var_chkQ_Spacial"] == null )
ViewState["var_chkQ_Spacial"] = string.Empty ;
return ViewState["var_chkQ_Spacial"].ToString() ;
}
set
{
ViewState["var_chkQ_Spacial"] = value ;
}
}
....
....
}
|
ประวัติการแก้ไข 2010-08-31 16:08:09 2010-08-31 16:09:38
 |
 |
 |
 |
Date :
2010-08-31 16:06:56 |
By :
blurEyes |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมว่าเกิดจากยังไม่ได้แฮนเดิลอีเว็นต์นะ
|
 |
 |
 |
 |
Date :
2010-08-31 16:28:04 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วต้องแฮนเดิลอีเว็นต์ยังไงอะครับ
ช่วยบอกทีครับ
|
 |
 |
 |
 |
Date :
2010-08-31 17:24:58 |
By :
accio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เลือกเอาวิธีใดวิธีหนึ่งนะ
ที่ code behide (.cs)
protected void Page_Load(object sender, EventArgs e)
{
....
....
....
....
chkQor2_CheckedChanged += new EventHandler(chkQor2_CheckedChanged);
}
ที่ .aspx
<asp:CheckBox ID="chkQor2" AutoPostBack="True" OnCheckedChanged="chkQor2_CheckedChanged" runat="server"></asp:CheckBox>
|
 |
 |
 |
 |
Date :
2010-08-31 21:03:26 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใส่ใน Page_Load แล้วเป็นแบบนี้ครับ
Cannot assign to 'chkQor2_CheckedChanged' because it is a 'method group'
เพราะอะไรครับ
อ้อ อีกอย่างทำไมต้องมีการแฮนเดิลอีเว็นต์ ด้วยคับ
ผลที่ทำกับไม่ทำต่างกันยังไงมั่งครับ
ปล. หรือว่าต้องไปกำหนดค่าอะไรอีกรึป่าวเนี่ย .......ฝากด้วยครับ
|
 |
 |
 |
 |
Date :
2010-09-01 00:51:50 |
By :
accio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่รับฝาก ไม่ใช่งานผม และเป็นหน้าที่คุณที่ต้องตามคำตอบเอง
แต่จะตอบตรง Cannot assign to 'chkQor2_CheckedChanged' because it is a 'method group'
- ผมโค้ดผิดแปละ ต้องเปลี่ยนเป็นแบบนี้ chkQor2.CheckedChanged += new EventHandler(chkQor2_CheckedChanged);
ทำไมต้องมีการแฮนเดิลอีเว็นต์
- เพราะเมื่อเราเปลี่ยนแปลงค่าใน checkbox จะเกิด event นึงขึ้นมา ถ้าเราไม่แฮนเดิลมันก็เกิดขึ้นเฉยๆ
เราจึงจำเป็นต้องจับเอา event นั้นมาจัดการแฮนเดิล เพื่อที่จะได้สามารถนำ event นั้นมาสั่งงานไง
|
 |
 |
 |
 |
Date :
2010-09-01 08:44:28 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่แน่ใจนะ ว่า checkbox เกิดจากการ binding data ใน page_load ไหม
เพราะเคยเจอว่ามัน post_back แล้วไม่ได้ค่า ต้องใส่
if(!Page.IsPostBack)
{
// code สำหรับ binding control
}
มันก็หาย ไม่งั้นมันจะได้ค่าเดิมตอน binding control
ไม่รู้นะผมมั่ว...
|
 |
 |
 |
 |
Date :
2010-09-01 10:55:37 |
By :
superpheak |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
chkQor2.CheckedChanged += new EventHandler(chkQor2_CheckedChanged);
ใส่ใน Page_Load แล้วครับ แต่ก็มิได้นำพา
คือ เหมือนเดิมทุกประการ ยังเป็นค่าว่างครับ
ไม่รู้จะทำไงแล้ว
|
 |
 |
 |
 |
Date :
2010-09-05 02:49:06 |
By :
accio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาโค้ดมาดู แบบเต็มๆ ทั้ง aspx และ code behide
|
 |
 |
 |
 |
Date :
2010-09-05 10:54:48 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จัดไปครับ
register.ascx(C#)
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="register.ascx.cs" Inherits="UI_WebUserControl" %>
<style type="text/css">
.style1
{
text-align: right;
width: 210px;
height: 25px;
}
.style2
{
width: 10px;
text-align: center;
height: 25px;
}
.style3
{
width: 680px;
height: 25px;
text-align: left;
}
#TextArea1
{
width: 260px;
height: 47px;
}
#TextArea2
{
width: 260px;
height: 47px;
}
.style5
{
width: 10px;
text-align: center;
}
#TextArea3
{
width: 260px;
height: 47px;
}
.style7
{
color: #FF0000;
font-size: small;
font-family: Arial, Helvetica, sans-serif;
}
.style8
{
color: #FF0000;
font-size: small;
}
.style9
{
width: 210px;
text-align: right;
height: 25px;
font-weight: bold;
}
.style11
{
width: 680px;
height: 25px;
text-align: left;
font-size: small;
color: #FF0000;
}
#TextArea3
{
width: 260px;
height: 47px;
}
#TextArea4
{
width: 260px;
height: 47px;
}
.style13
{
text-align: right;
height: 25px;
font-weight: bold;
}
.style14
{
font-size: small;
font-family: Arial, Helvetica, sans-serif;
}
.style15
{
text-align: right;
width: 210px;
height: 26px;
}
.style16
{
width: 10px;
text-align: center;
height: 26px;
}
.style17
{
width: 680px;
height: 26px;
text-align: left;
}
.style19
{
width: 175px;
}
.style20
{
width: 376px;
}
</style>
<table cellpadding="0" cellspacing="0" width="900">
<tr>
<td bgcolor="#FF9999">
<b style="text-align: left">:: ข้อมูลทั่วไป</b></td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="900">
<tr>
<td class="style1">
ชือ</td>
<td class="style2">
:</td>
<td class="style3">
<asp:DropDownList ID="DropPreName" runat="server" Height="22px" Width="70px">
<asp:ListItem>นาย</asp:ListItem>
<asp:ListItem>นางสาว</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="tbxName" runat="server" Width="170px" Height="22px"></asp:TextBox>
<span class="style8">*</span>
นามสกุล
<asp:TextBox ID="tbxName2" runat="server" Width="170px"></asp:TextBox>
<span class="style8">*</span></td>
</tr>
<tr>
<td class="style1">
หมายเลขบัตรประจำตัวประชาชน</td>
<td class="style2">
:</td>
<td class="style3">
<asp:TextBox ID="tbxIDCard" runat="server" Width="209px" MaxLength="13"></asp:TextBox>
<span class="style7">* ป้อนตัวเลข 13 ตัวเท่านั้น</span></td>
</tr>
<tr>
<td class="style1">
วัน/เดือน/ปีเกิด</td>
<td class="style2">
:</td>
<td class="style3">
<asp:DropDownList ID="Dropdate" runat="server" Height="22px" Width="43px">
<asp:ListItem></asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
<asp:ListItem>9</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
<asp:ListItem Value="13"></asp:ListItem>
<asp:ListItem Value="14"></asp:ListItem>
<asp:ListItem Value="15"></asp:ListItem>
<asp:ListItem Value="16"></asp:ListItem>
<asp:ListItem Value="17"></asp:ListItem>
<asp:ListItem Value="18"></asp:ListItem>
<asp:ListItem Value="19"></asp:ListItem>
<asp:ListItem Value="20"></asp:ListItem>
<asp:ListItem Value="21"></asp:ListItem>
<asp:ListItem Value="22"></asp:ListItem>
<asp:ListItem Value="23"></asp:ListItem>
<asp:ListItem Value="24"></asp:ListItem>
<asp:ListItem Value="25"></asp:ListItem>
<asp:ListItem Value="26"></asp:ListItem>
<asp:ListItem Value="27"></asp:ListItem>
<asp:ListItem Value="28"></asp:ListItem>
<asp:ListItem Value="29"></asp:ListItem>
<asp:ListItem Value="30">30</asp:ListItem>
<asp:ListItem Value="31"></asp:ListItem>
</asp:DropDownList>
/
<asp:DropDownList ID="DropMount" runat="server" Height="22px" Width="100px">
<asp:ListItem></asp:ListItem>
<asp:ListItem>มกราคม</asp:ListItem>
<asp:ListItem>กุมภาพันธ์</asp:ListItem>
<asp:ListItem>มีนาคม</asp:ListItem>
<asp:ListItem>เมษายน</asp:ListItem>
<asp:ListItem>พฤษภาคม</asp:ListItem>
<asp:ListItem>มิถุนายน</asp:ListItem>
<asp:ListItem>กรกฎาคม</asp:ListItem>
<asp:ListItem>สิงหาคม</asp:ListItem>
<asp:ListItem>กันยายน</asp:ListItem>
<asp:ListItem>ตุลาคม</asp:ListItem>
<asp:ListItem>พฤศจิกายน</asp:ListItem>
<asp:ListItem>ธันวาคม</asp:ListItem>
</asp:DropDownList>
/
<asp:TextBox ID="tbxYear" runat="server" MaxLength="4" Width="70px"></asp:TextBox>
<span class="style7">* </span><span class="style14">(วัน/เดือน/ปี ตัวอย่าง 1/1/25xx)</span></td>
</tr>
<tr>
<td class="style1">
เพศ</td>
<td class="style2">
:</td>
<td class="style3">
<asp:RadioButtonList ID="RadioSex" runat="server"
RepeatDirection="Horizontal" Height="24px">
<asp:ListItem>ชาย</asp:ListItem>
<asp:ListItem>หญิง</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="style1">
อายุ</td>
<td class="style2">
:</td>
<td class="style3">
<asp:TextBox ID="tbxAge" runat="server" Width="61px" MaxLength="2"></asp:TextBox>
ปี</td>
</tr>
<tr>
<td class="style1" valign="top">
ที่อยู่</td>
<td class="style2" valign="top">
:</td>
<td class="style3">
<asp:TextBox ID="tbxAddress" runat="server" TextMode="MultiLine" Width="233px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
จังหวัด</td>
<td class="style2">
:</td>
<td class="style3">
<asp:TextBox ID="tbxProvince" runat="server" Width="193px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
รหัสไปรษรย์</td>
<td class="style2">
:</td>
<td class="style3">
<asp:TextBox ID="tbxZipcode" runat="server" MaxLength="5"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
โทรศัพท์</td>
<td class="style2">
:</td>
<td class="style3">
<asp:TextBox ID="tbxPhone" runat="server" Width="182px" MaxLength="10"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
โทรศัพท์มือถือ</td>
<td class="style2">
:</td>
<td class="style3">
<asp:TextBox ID="tbxMobie" runat="server" Width="182px" MaxLength="10"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
ชื่อ-สกุล บิดา</td>
<td class="style2">
:</td>
<td class="style3">
<asp:TextBox ID="tbxFaNane" runat="server" Width="211px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
อายุ</td>
<td class="style2">
:</td>
<td class="style3">
<asp:TextBox ID="tbxFaAge" runat="server" Width="61px" MaxLength="2"></asp:TextBox>
ปี</td>
</tr>
<tr>
<td class="style1">
อาชีพ</td>
<td class="style2">
:</td>
<td class="style3">
<asp:DropDownList ID="DropFaOcupa" runat="server" Width="130px">
<asp:ListItem>เลือกอาชีพ</asp:ListItem>
<asp:ListItem>รับจ้างทั่วไป
</asp:ListItem>
<asp:ListItem>ค้าขาย/ธุรกิจส่วนตัว</asp:ListItem>
<asp:ListItem>เกษตรกร</asp:ListItem>
<asp:ListItem>พนักงานเอกชน</asp:ListItem>
<asp:ListItem>ข้าราชการ/รัฐวิสาหกิจ
</asp:ListItem>
<asp:ListItem>อื่นๆ</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style1">
ชื่อ-สกุล มารดา</td>
<td class="style2">
:</td>
<td class="style3">
<asp:TextBox ID="tbxMaName" runat="server" Width="211px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
อายุ</td>
<td class="style2">
:</td>
<td class="style3">
<asp:TextBox ID="tbxMaAge" runat="server" Width="61px" MaxLength="2"></asp:TextBox>
ปี</td>
</tr>
<tr>
<td class="style1">
อาชีพ</td>
<td class="style2">
:</td>
<td class="style3">
<asp:DropDownList ID="DropMaOcupa" runat="server" Width="130px">
<asp:ListItem>เลือกอาชีพ</asp:ListItem>
<asp:ListItem>รับจ้างทั่วไป
</asp:ListItem>
<asp:ListItem>ค้าขาย/ธุรกิจส่วนตัว</asp:ListItem>
<asp:ListItem>เกษตรกร</asp:ListItem>
<asp:ListItem>พนักงานเอกชน</asp:ListItem>
<asp:ListItem>ข้าราชการ/รัฐวิสาหกิจ
</asp:ListItem>
<asp:ListItem>อื่นๆ</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style1">
</td>
<td class="style2">
</td>
<td class="style3">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#FF9999">
<b> :: คุณสมบัติการสมัคร</b></td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="900">
<tr>
<td class="style1">
สมัครโดยใช้คุณวุฒิ</td>
<td class="style2">
:</td>
<td class="style3">
<table cellpadding="0" cellspacing="0">
<tr>
<td class="style19">
<asp:RadioButtonList ID="RadioLevel" runat="server"
RepeatDirection="Horizontal">
<asp:ListItem Value="1">ม.6</asp:ListItem>
<asp:ListItem Value="2">ปวช.</asp:ListItem>
<asp:ListItem Value="3">ปวส.</asp:ListItem>
</asp:RadioButtonList>
</td>
<td class="style20">
<span class="style8">*</span> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="style1">
สาขาวิชาที่กำลังศึกษา</td>
<td class="style2">
:</td>
<td class="style3">
<asp:TextBox ID="tbxMajor" runat="server" Width="291px"></asp:TextBox>
<span class="style8">*</span></td>
</tr>
<tr>
<td class="style1">
ชือสถาบันที่กำลังศึกษา</td>
<td class="style2">
:</td>
<td class="style3">
<asp:TextBox ID="tbxSchoolName" runat="server" Width="260px"></asp:TextBox>
<span class="style8">*</span></td>
</tr>
<tr>
<td class="style1" valign="top">
ที่อยู่
<td class="style2" valign="top">
:</td>
<td class="style3" valign="top">
<asp:TextBox ID="tbxAddSchool" runat="server" TextMode="MultiLine"
Width="305px" Height="109px"></asp:TextBox>
<span class="style8">*</span></td>
</tr>
<tr>
<td class="style1">
เกรดเฉลี่ย</td>
<td class="style5">
:</td>
<td class="style3">
<asp:TextBox ID="tbxGPAX" runat="server" Width="91px" MaxLength="4"></asp:TextBox>
<span class="style8">*</span></td>
</tr>
<tr>
<td class="style1" valign="top">
ความสามารถพิเศษ</td>
<td class="style2" valign="top">
:</td>
<td class="style3">
<asp:RadioButtonList ID="RadioSport" runat="server">
<asp:ListItem Value="2">กีฬา</asp:ListItem>
<asp:ListItem Value="3">ดนตรี</asp:ListItem>
<asp:ListItem Value="4">ร้องเพลง</asp:ListItem>
<asp:ListItem Value="5">นาฏศิลป์</asp:ListItem>
<asp:ListItem Value="6">กิจกรรมโรงเรียน</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td bgcolor="#FF9999">
<b> :: ข้อมูลการสมัคร</b> </td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="900">
<tr>
<td class="style9" bgcolor="#FFCC99">
สมัครในโควตา</td>
<td class="style2" bgcolor="#FFCC99">
:</td>
<td class="style3" bgcolor="#FFCC99">
<asp:RadioButtonList ID="RadiOrganize" runat="server"
RepeatDirection="Horizontal"
onselectedindexchanged="RadiOrganize_SelectedIndexChanged"
AutoPostBack="True">
<asp:ListItem Value="sq01">โรงเรียน</asp:ListItem>
<asp:ListItem Value="sq02">อบต.</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="style1">
</td>
<td class="style2">
</td>
<td class="style11">
** กรณีสมัครหลักสูตรครุศาสตร์บัณฑิต เกรดเฉลียไม่ต่ำกว่า 2.00</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="900" id="tb_1">
<tr>
<td class="style13" bgcolor="#FFFF99">
สำหรับโควตาโรงเรียน</td>
<td class="style2">
:</td>
<td class="style3">
<asp:CheckBox ID="chkQsh1" runat="server" Text="เรียนดี"
oncheckedchanged="chkQsh1_CheckedChanged" AutoPostBack="True"/>
<span class="style8"> [</span><asp:CheckBox ID="chkQsh33" runat="server" ForeColor="Red"
oncheckedchanged="chkQsh33_CheckedChanged" Text="ขอรับทุนเรียนดี" />
<span class="style8"> **เกรดเฉลี่ยไม่ต่ำกว่า 2.80]</span></td>
</tr>
<tr>
<td class="style1">
เลือกลำดับที่ 1 </td>
<td class="style2">
:</td>
<td class="style3">
<asp:DropDownList ID="DropMajorQ1Sh1" runat="server" Width="250px"
DataSourceID="SqlDataSource1" DataTextField="Ma_name" DataValueField="Ma_No">
<asp:ListItem Selected="True">โปรดเลือกสาขาอันดับที่ 1</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DB_recruitingSystemConnection %>"
SelectCommand="SELECT [Ma_No], [Ma_name] FROM [Major]">
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td class="style15">
เลือกลำดับที่ 2 </td>
<td class="style16">
:</td>
<td class="style17">
<asp:DropDownList ID="DropMajorQ1Sh2" runat="server" Width="250px"
DataSourceID="SqlDataSource1" DataTextField="Ma_name" DataValueField="Ma_No">
<asp:ListItem>โปรดเลือกสาขาอันดับที่ 2</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style13" valign="top" bgcolor="#FFFF99">
สำหรับโควตาโรงเรียน</td>
<td class="style2" valign="top">
:</td>
<td class="style3">
<asp:CheckBox ID="chkQsh2" runat="server" Text="กิจกรรมพิเศษ"
oncheckedchanged="chkQsh2_CheckedChanged" AutoPostBack="True" />
</td>
</tr>
<tr>
<td class="style1">
เลือกลำดับที่ 1 </td>
<td class="style2">
:</td>
<td class="style3">
<asp:DropDownList ID="DropMajorQ2Sh1" runat="server" Width="250px"
DataSourceID="SqlDataSource1" DataTextField="Ma_name" DataValueField="Ma_No">
<asp:ListItem>โปรดเลือกสาขาอันดับที่ 1</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style1">
เลือกลำดับที่ 2 </td>
<td class="style2">
:</td>
<td class="style3">
<asp:DropDownList ID="DropMajorQ2Sh2" runat="server" Width="250px"
DataSourceID="SqlDataSource1" DataTextField="Ma_name" DataValueField="Ma_No">
<asp:ListItem>โปรดเลือกสาขาอันดับที่ 2</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" width="900" id="tb_2">
<tr>
<td class="style13" bgcolor="#CCFF66">
สำหรับโควตา อบต.</td>
<td class="style2" bgcolor="#CCFF66">
:</td>
<td class="style3" bgcolor="#CCFF66">
<asp:CheckBox ID="chkQor1" runat="server" Text="เรียนดี"
oncheckedchanged="chkQor1_CheckedChanged" />
<br />
<asp:CheckBox ID="chkQor2" runat="server" Text="กิจกรรมพิเศษ"
oncheckedchanged="chkQor2_CheckedChanged" />
</td>
</tr>
<tr>
<td class="style1">
จาก อบต. </td>
<td class="style2">
:</td>
<td class="style3">
<asp:TextBox ID="tbxOrName" runat="server" Width="279px"></asp:TextBox>
<span class="style8">*</span></td>
</tr>
<tr>
<td class="style1" valign="top">
ที่อยู่</td>
<td class="style2" valign="top">
:</td>
<td class="style3" valign="top">
<asp:TextBox ID="tbxOrAdd" runat="server" TextMode="MultiLine" Width="296px"
Height="108px"></asp:TextBox>
<span class="style8">*</span></td>
</tr>
<tr>
<td class="style1">
เลือกลำดับที่ 1 </td>
<td class="style2">
:</td>
<td class="style3">
<asp:DropDownList ID="DropMajorQor1" runat="server" Width="250px"
DataSourceID="SqlDataSource1" DataTextField="Ma_name" DataValueField="Ma_No">
<asp:ListItem>โปรดเลือกสาขาอันดับที่ 1</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style1">
เลือกลำดับที่ 2 </td>
<td class="style2">
:</td>
<td class="style3">
<asp:DropDownList ID="DropMajorQor2" runat="server" Width="250px"
DataSourceID="SqlDataSource1" DataTextField="Ma_name" DataValueField="Ma_No">
<asp:ListItem>โปรดเลือกสาขาอันดับที่ 2</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSend" runat="server" Text="ส่งข้อมูลการสมัคร"
onclick="btnSend_Click" />
<asp:Button ID="btnCancel" runat="server" Text="ยกเลิก"
onclick="btnCancel_Click" style="height: 26px" />
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
|
 |
 |
 |
 |
Date :
2010-09-05 15:42:55 |
By :
accio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
register.ascx.cs (C#)
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Web.Configuration;
public partial class UI_WebUserControl : System.Web.UI.UserControl
{
Student aStudent;
StudentData aStudentData = new StudentData();
Apply aApply;
ApplyData aApplyData = new ApplyData();
string chkQ_Learn, chkQ_Spacial, chkLearn_con_ID, Or_Name1, Or_Add1, dropQ_Learn_1, dropQ_Learn_2, dropQ_Spacial_1, dropQ_Spacial_2, radioSpacial_con_ID;
//ล้างค่าในคอนโทรลต่าง ๆ ให้เป็นค่าเริ่มต้น
private void ClearDataControl()
{
tbxName.Text = "";
tbxName2.Text = "";
tbxIDCard.Text = "";
RadioSex.ClearSelection();
Dropdate.ClearSelection();
DropMount.ClearSelection();
tbxYear.Text = "";
tbxAge.Text = "";
tbxAddress.Text = "";
tbxProvince.Text = "";
tbxZipcode.Text = "";
tbxPhone.Text = "";
tbxMobie.Text = "";
tbxFaNane.Text = "";
tbxFaAge.Text = "";
tbxMaName.Text = "";
tbxMaAge.Text = "";
RadioLevel.ClearSelection();
tbxMajor.Text = "";
DropFaOcupa.ClearSelection();
tbxSchoolName.Text = "";
tbxAddSchool.Text = "";
tbxGPAX.Text = "";
RadioSport.ClearSelection();
RadiOrganize.ClearSelection();
chkQsh1.Checked = false;
chkQsh2.Checked = false;
chkQsh33.Checked = false;
DropMajorQ1Sh1.ClearSelection();
DropMajorQ1Sh2.ClearSelection();
DropMajorQ2Sh1.ClearSelection();
DropMajorQ2Sh2.ClearSelection();
chkQor1.Checked = false;
chkQor2.Checked = false;
DropMajorQor1.ClearSelection();
DropMajorQor2.ClearSelection();
tbxOrName.Text = "";
tbxOrAdd.Text = "";
}
public void MessageBox(string msg)
{
Label lbl = new Label();
lbl.Text = "<script language='javascript'>" + Environment.NewLine + "window.alert('" + msg + "')</script>";
Page.Controls.Add(lbl);
}
//กำหนดค่าให้กับ Object Course
private void SetDataControl()
{
string autoNumber = AutoNumber.AutoId("Student", "ID_Stu", "00000", "00001", "54", 2, 5);
aStudent = new Student();
aStudent.ID_Stu = autoNumber.ToString();
aStudent.Stu_pre = DropPreName.Text.ToString();
aStudent.Stu_name = tbxName.Text.ToString();
aStudent.Stu_name2 = tbxName2.Text.ToString();
aStudent.ID_card = tbxIDCard.Text.ToString();
aStudent.Stu_birth = Dropdate.Text.ToString() + DropMount.Text.ToString() + tbxYear.Text.ToString();
aStudent.Stu_sex = RadioSex.SelectedValue.ToString();
aStudent.Stu_age = tbxAge.Text.ToString();
aStudent.Stu_add = tbxAddress.Text.ToString();
aStudent.Stu_city = tbxProvince.Text.ToString();
aStudent.Zip_code = tbxZipcode.Text.ToString();
aStudent.phone = tbxPhone.Text.ToString();
aStudent.mobile = tbxMobie.Text.ToString();
aStudent.level_Stu = RadioLevel.SelectedValue.ToString();
aStudent.Stu_major = tbxMajor.Text.ToString();
aStudent.SchoolName = tbxSchoolName.Text.ToString();
aStudent.AddSchool = tbxAddSchool.Text.ToString();
aStudent.GPAX = tbxGPAX.Text.ToString();
aStudent.Fa_name = tbxFaNane.Text.ToString();
aStudent.Fa_age = tbxFaAge.Text.ToString();
aStudent.Fa_work = DropFaOcupa.Text.ToString();
aStudent.Ma_age = tbxMaAge.Text.ToString();
aStudent.Ma_name = tbxMaName.Text.ToString();
aStudent.Ma_work = DropMaOcupa.Text.ToString();
aApply = new Apply();
//set เงื่อนไขการสมัครเรียนดี
if (chkLearn_con_ID == "1")
{
aApply.Learn_con_ID = "1";
}
else
{
aApply.Learn_con_ID = "0";
}
//set เงื่อนไขการสมัครกิจกรรม
if (radioSpacial_con_ID != "")
{
aApply.Spacial_con_ID = radioSpacial_con_ID;
}
else
{
aApply.Spacial_con_ID = "-";
}
//set ที่่อยู่ของ Organize ที่ใช้สมัคร
if (RadiOrganize.SelectedItem.ToString() == "โรงเรียน")
{
Or_Name1 = tbxSchoolName.Text.ToString();
Or_Add1 = tbxAddSchool.Text.ToString();
}
else
{
Or_Name1 = tbxOrName.Text.ToString();
Or_Add1 = tbxOrAdd.Text.ToString();
}
aApply.ID_Stu = autoNumber.ToString();
aApply.Source_Q = RadiOrganize.SelectedItem.ToString();
aApply.Q_Learn = chkQ_Learn;
aApply.Q_Learn_1 = dropQ_Learn_1;
aApply.Q_Learn_2 = dropQ_Learn_2;
aApply.Q_Spacial = chkQ_Spacial;
aApply.Q_Spacial_1 = dropQ_Spacial_1;
aApply.Q_Spacial_2 = dropQ_Spacial_2;
aApply.Or_Name = Or_Name1;
aApply.Or_Add = Or_Add1;
}
//เมื่อคลิกปุ่มส่งข้อมูล
protected void btnSend_Click(object sender, EventArgs e)
{
/*
if (tbxIDCard.Text.Trim() == "")
{
MessageBox("กรุณาระบุเลขประจำตัวประชาชน");
tbxIDCard.Focus();
}
else if (tbxYear.Text.Trim() == "")
{
MessageBox("กรุณาใส่ วัน/เดือน/ปี เกิด");
//Dropdate.Focus();
}
else if (dropQ_Spacial_1 != "" || dropQ_Spacial_2 != "")
{
MessageBox("กรุณาระบุความสามารถของคุณด้วย");
RadioSport.Focus();
}
else
{*/
SetDataControl();
if (aStudentData.Insert(aStudent) > 0)
{
// MessageBox("ระบบได้ทำการบันทึกข้อมูล เรียบร้อยแล้ว");
MessageBox("(aStudentData.Insert(aStudent) ทำงานอยู่ บันทึกแล้ว");
ClearDataControl();
if (aApplyData.Insert(aApply) > 0)
{
MessageBox("(aApplyData.Insert(aApply) ทำงานอยู่");
MessageBox("ประเภทโควตา =" + aApply.Source_Q + " เรียนดี=" + aApply.Q_Learn + " อันที่ 1 =" + aApply.Q_Learn_1 + " อันที่ 2=" + aApply.Q_Learn_2 + " กิจกรรม=" + aApply.Q_Spacial + " อันที่ 1 =" + aApply.Q_Spacial_1 + " อันที่ 2 =" + aApply.Q_Spacial_2 + " สถานทุนเรียนดี = " + aApply.Learn_con_ID + " สถานะกิจกรรม = " + aApply.Spacial_con_ID + " หน่วยงาน = " + aApply.Or_Name);
MessageBox("รหัสนักศึกษาคือ " + aApply.ID_Stu);
}
else
{
MessageBox("ไม่ทำงาน ที่(aApplyData.Insert(aApply)");
MessageBox("ประเภทโควตา =" + aApply.Source_Q + " เรียนดี=" + aApply.Q_Learn + " อันที่ 1 =" + aApply.Q_Learn_1 + " อันที่ 2=" + aApply.Q_Learn_2 + " กิจกรรม=" + aApply.Q_Spacial + " อันที่ 1 =" + aApply.Q_Spacial_1 + " อันที่ 2 =" + aApply.Q_Spacial_2 + " สถานทุนเรียนดี = " + aApply.Learn_con_ID + " สถานะกิจกรรม = " + aApply.Spacial_con_ID + " หน่วยงาน = " + aApply.Or_Name);
MessageBox("รหัสนักศึกษาคือ " + aApply.ID_Stu);
}
//ClearDataControl();
}
else
{
MessageBox("Method (aStudentData.Insert(aStudent) ไม่ทำงาน");
//MessageBox("บันทึกข้อมูล ไม่ได้");
}
//}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
SetDataControl();
MessageBox("เรียนดี = " + chkQ_Learn + " อันดับที่ 1 = " + dropQ_Learn_1 + " อันดับที่ 2 = " + dropQ_Learn_2);
ClearDataControl();
}
protected void Page_Load(object sender, EventArgs e)
{
disableDataControlQoata1();
disableDataControlQoata2();
chkQsh1.CheckedChanged += new EventHandler(chkQsh1_CheckedChanged);
chkQsh2.CheckedChanged += new EventHandler(chkQsh2_CheckedChanged);
chkQsh33.CheckedChanged += new EventHandler(chkQsh33_CheckedChanged);
chkQor1.CheckedChanged += new EventHandler(chkQor1_CheckedChanged);
chkQor2.CheckedChanged += new EventHandler(chkQor2_CheckedChanged);
// chkQsh1_CheckedChanged += new EventHandler(chkQsh1_CheckedChanged);
// chkQsh2_CheckedChanged += new EventHandler(chkQsh2_CheckedChanged);
// chkQsh33_CheckedChanged += new EventHandler(chkQsh33_CheckedChanged);
// chkQor1_CheckedChanged += new EventHandler(chkQor1_CheckedChanged);
// chkQor2_CheckedChanged += new EventHandler(chkQor2_CheckedChanged);
}
public void RadiOrganize_SelectedIndexChanged(object sender, EventArgs e)
{
//เมื่อคลิกเลือกโควต้าหนึ่ง จะทำให้อีกอันใช้ไม่ได้
if (RadiOrganize.SelectedItem.ToString() == "โรงเรียน")
{
enableDataControlQoata1();
disableDataControlQoata2();
Page.MaintainScrollPositionOnPostBack = true;
DropMajorQ1Sh1.Enabled = false;
DropMajorQ1Sh2.Enabled = false;
DropMajorQ2Sh1.Enabled = false;
DropMajorQ2Sh2.Enabled = false;
}
else if (RadiOrganize.SelectedItem.ToString() == "อบต.")
{
enableDataControlQoata2();
disableDataControlQoata1();
Page.MaintainScrollPositionOnPostBack = true;
}
}
private void disableDataControlQoata1()
{ //control Qoata1
chkQsh1.Enabled = false;
chkQsh2.Enabled = false;
chkQsh33.Enabled = false;
DropMajorQ1Sh1.Enabled = false;
DropMajorQ1Sh2.Enabled = false;
DropMajorQ2Sh1.Enabled = false;
DropMajorQ2Sh2.Enabled = false;
}
private void disableDataControlQoata2()
{
//control Qoata2
chkQor1.Enabled = false;
chkQor2.Enabled = false;
tbxOrAdd.Enabled = false;
tbxOrName.Enabled = false;
DropMajorQor1.Enabled = false;
DropMajorQor2.Enabled = false;
}
private void enableDataControlQoata1()
{
chkQsh1.Enabled = true;
chkQsh2.Enabled = true;
chkQsh33.Enabled = false;
DropMajorQ1Sh1.Enabled = false;
DropMajorQ1Sh2.Enabled = false;
DropMajorQ2Sh1.Enabled = false;
DropMajorQ2Sh2.Enabled = false;
}
private void enableDataControlQoata2()
{
chkQor1.Enabled = true;
chkQor2.Enabled = true;
tbxOrAdd.Enabled = true;
tbxOrName.Enabled = true;
DropMajorQor1.Enabled = true;
DropMajorQor2.Enabled = true;
}
private void chkQoata()
{
if ((this.chkQsh1.Checked == true) && (this.chkQsh2.Checked == true))
{
DropMajorQ1Sh1.Enabled = true;
DropMajorQ1Sh2.Enabled = true;
DropMajorQ2Sh1.Enabled = true;
DropMajorQ2Sh2.Enabled = true;
chkQsh1.Enabled = true;
chkQsh2.Enabled = true;
chkQsh33.Enabled = true;
}
else if(this.chkQsh1.Checked == true)
{
DropMajorQ1Sh1.Enabled = true;
DropMajorQ1Sh2.Enabled = true;
DropMajorQ2Sh1.Enabled = false;
DropMajorQ2Sh2.Enabled = false;
chkQsh1.Enabled = true;
chkQsh2.Enabled = true;
chkQsh33.Enabled = true;
}
else if (this.chkQsh2.Checked == true)
{
DropMajorQ1Sh1.Enabled = false;
DropMajorQ1Sh2.Enabled = false;
DropMajorQ2Sh1.Enabled = true;
DropMajorQ2Sh2.Enabled = true;
chkQsh1.Enabled = true;
chkQsh2.Enabled = true;
chkQsh33.Enabled = false;
}
}
protected void chkQsh1_CheckedChanged(object sender, EventArgs e)
{
if (this.chkQsh1.Checked == true)
{
chkQoata();
//this.chkQ_Learn = "เรียนดี";
chkQ_Learn = chkQsh1.Text.ToString();
this.dropQ_Learn_1 = DropMajorQ1Sh1.SelectedItem.ToString();
this.dropQ_Learn_2 = DropMajorQ1Sh2.SelectedItem.ToString();
}
else
{
this.chkQ_Learn = "-";
this.dropQ_Learn_1 = "-";
this.dropQ_Learn_2 = "-";
chkQsh1.Enabled = true;
chkQsh2.Enabled = true;
DropMajorQ1Sh1.ClearSelection();
DropMajorQ1Sh2.ClearSelection();
chkQsh33.Checked = false;
}
}
protected void chkQsh2_CheckedChanged(object sender, EventArgs e)
{
if (this.chkQsh2.Checked == true)
{
chkQoata();
//this.chkQ_Spacial = "กิจกรรมพิเศษ";
chkQ_Spacial = chkQsh2.Text.ToString();
this.dropQ_Spacial_1 = DropMajorQ2Sh1.SelectedItem.ToString();
this.dropQ_Spacial_2 = DropMajorQ2Sh2.SelectedItem.ToString();
radioSpacial_con_ID = RadioSport.SelectedItem.ToString();
}
else
{
this.chkQ_Spacial = "-";
this.dropQ_Spacial_1 = "-";
this.dropQ_Spacial_2 = "-";
chkQsh1.Enabled = true;
chkQsh2.Enabled = true;
DropMajorQ2Sh1.ClearSelection();
DropMajorQ2Sh2.ClearSelection();
}
}
protected void chkQor1_CheckedChanged(object sender, EventArgs e)
{
if (this.chkQor1.Checked == true)
{
// this.chkQ_Learn = "เรียนดี";
chkQ_Learn = chkQor1.Text.ToString();
dropQ_Learn_1 = DropMajorQor1.SelectedItem.ToString();
dropQ_Learn_2 = DropMajorQor2.SelectedItem.ToString();
}
else
{
chkQ_Learn = "ไม่ระบุ";
dropQ_Learn_1 = "ไม่ระบุ";
dropQ_Learn_2 = "ไม่ระบุ";
}
}
protected void chkQor2_CheckedChanged(object sender, EventArgs e)
{
if (this.chkQor2.Checked == true)
{
// this.chkQ_Spacial = "กิจกรรมพิเศษ";
chkQ_Spacial = chkQor2.Text.ToString();
this.dropQ_Spacial_1 = DropMajorQor1.SelectedItem.ToString();
this.dropQ_Spacial_2 = DropMajorQor2.SelectedItem.ToString();
radioSpacial_con_ID = RadioSport.SelectedItem.ToString();
}
else if (this.chkQor2.Checked==false)
{
this.chkQ_Spacial = "-";
this.dropQ_Spacial_1 = "-";
this.dropQ_Spacial_2 = "-";
}
}
protected void chkQsh33_CheckedChanged(object sender, EventArgs e)
{
if (chkQsh33.Checked == true)
{
this.chkLearn_con_ID = "1";
}
else
{
this.chkLearn_con_ID = "0";
}
}
}
|
 |
 |
 |
 |
Date :
2010-09-05 15:44:39 |
By :
accio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รู้แระ
พวกที่แฮนเดิลแบบนี้ ไว้
Code (C#)
<asp:CheckBox ID="chkQsh33" runat="server" ForeColor="Red"oncheckedchanged="chkQsh33_CheckedChanged" Text="ขอรับทุนเรียนดี" />
ไม่ต้องแฮนเดิลแบบนี้อีก
Code (C#)
chkQsh33.CheckedChanged += new EventHandler(chkQsh33_CheckedChanged);
ย้ำคิดย้ำทำจริง บางอย่างทำเยอะๆ ใช่ว่าจะดีนะ บอกไว้ตรง no.9 เอาแบบใดแบบหนึ่งแล้วด้วย แสงดว่าไม่ได้ดูเลยนะ
ที่มันไม่ทำ method ก็เพราะไป disable controls มันอ่ะดิ ตรงเนี้ย
Code (C#)
protected void Page_Load(object sender, EventArgs e)
{
disableDataControlQoata1();
disableDataControlQoata2();
chkQsh1.CheckedChanged += new EventHandler(chkQsh1_CheckedChanged);
chkQsh2.CheckedChanged += new EventHandler(chkQsh2_CheckedChanged);
chkQsh33.CheckedChanged += new EventHandler(chkQsh33_CheckedChanged);
chkQor1.CheckedChanged += new EventHandler(chkQor1_CheckedChanged);
chkQor2.CheckedChanged += new EventHandler(chkQor2_CheckedChanged);
}
เอา if (!IsPostBack) ไปครอบ disableDataControlQoata1(); กับ disableDataControlQoata2(); ซะ
แล้วอย่าลืมตรงแฮนเดิลด้วยล่ะ เอาซักแบบ
|
 |
 |
 |
 |
Date :
2010-09-05 20:26:19 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้างั้นก็แสดงว่าทีแรกผมก็คงแฮนเดิล ไปแล้ว ก็ไม่รู้นี่นาว่าไอ้แบบทีสองคือการแฮนเดิล ด้วย
พอมาเห็นว่าใน Page_Load ก็เลยได้ใส่ไปอีก
//////////////////////////////////////////////////////////////////////
แล้วที่เห็นว่า disable controls ใน Page_Load คือ disable แค่ตอน Page_Load มันจะมีช่วงที่ทำให้มันทำงานอยู่ครับประมาณว่า เลือก radio Qoata1ก็จะEnableและทำให้อีกตัวใช้ไม่ได้ คือต้องเลือก Qoata1ก็หรือ Qoata2 อย่างใดอย่างหนึ่งครับ
/////////////////////////
ผมลองเอา if (!IsPostBack) ไปใส่แล้วครับ ก็ยังคงเป็นผลเหมืนเดิม คือตัวแปรรับค่าว่างเข้าไป
///////////////////////
ผมน่ะสงสัยว่าอาจจะเป็นเพราะว่า เช็คบ๊อก chkQsh1 และchkQsh2 ทำการPostBackไปแล้วก็เหมือนว่ามีการส่งค่าไปแล้ว
ทำให้ตัวแปรนั้นว่างลงรึเปล่า
ถ้าไม่ใช่ทำไม chkQor1 และchkQor2 ถึงเก็บค่าลงตัวแปรได้ เพราะสองส่วนนี้จะต่างกันแค่ มีการPostBack กับไม่มีPostBack
|
 |
 |
 |
 |
Date :
2010-09-06 22:03:19 |
By :
accio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวแปรเจ๋ยๆ ไม่ได้เก็บเข้า viewstate ค่าต่างๆก้อร่วงหมดดิคะ
|
 |
 |
 |
 |
Date :
2010-09-06 22:12:39 |
By :
blurEyes |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สุดยอดครับ คุณStupid gurl
ทำได้แล้วครับ (เฉพาะเช็คบ็อกที่ PostBack )
////////////////////////////
คือ ผมใช้ viewstate ในการเก็บค่าจาก เช็คบ๊อกที่มี PostBack แล้วได้ผลนะครับ
แต่ อยากรู้ว่า กรณีเป็นDropDownList ที่ไม่ได้PostBack ซึ่งก็ไม่ได้แฮนเดิลอีเวนต์ จะทำไงให้มันเก็บค่าได้
ผมลองเก็บใน viewstate แล้วก็ไม่ได้ เก็บในตัวแปรปกติแล้วก็ไม่ได้เช่นเดียวกันครับ
แบบนี้นะครับ viewstate ["DropQ1"]=DropMajorQ1Sh1.SelectedItem.ToString();
viewstate ["DropQ1"]=(เป็นค่าที่ว่าง)
///////////////////////////
แสดงว่า viewstate มีการใช้ที่จำเพาะหรอครับ
ปล.DropDownList จะ enable ได้ก็ต่อเมื่อ เช็คบ๊อก เป็นทรู คือทำการคลิกเลือกแล้วเท่านั้นครับ
|
 |
 |
 |
 |
Date :
2010-09-07 02:21:16 |
By :
accio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
DropDownList ที่ไม่ได้PostBack คือไม่ได้สั่ง autopostback=true ใช่ปะคะ
เข้าใจว่าปัญหาเกิดจากความไม่เข้าใจเรื่องกลไกการทำงานของ asp.net
ฝึกเขียนจากง่ายไปหายาก ฝึกเยอะๆจะเข้าใจค่ะเพราะ programming เป็นทักษะที่เกิดจากการฝึกเสียกว่า 40%
ส่วนเรื่อง ViewState มีข้อจำกัดอะไร ViewState จะคงอยู่ตราบที่ instance ของ page นั้นยัง active ที่ browser ค่ะ
และจะมีขอบเขตภายใน Page เท่านั้น
ViewState เป็น 1 ในวิธีการจัดการ instance ของข้อมุลของ ASP.NET
หรือที่เรียกกันว่า state management ซึ่งมีหลายประเภทได้แก่
- View state
- Control state
- Hidden fields
- Cookies
- Query strings
- Application state
- Session state
- Profile Properties
คงไม่ต้องแจงรายละเอียดมังคะเพราะอาจารย์จะสอนใน class ให้อยู่แล้ว
ส่วนวิธีการแก้ไข การที่จะเก็บค่ามันได้ในกรณีนี้ก้อต้องไปเก็บค่าตอน page postback จากกรณีอื่น ไม่มีทางเลี่ยงค่ะ
เช่นจากการกด button หรือกำหนดให้ auto postback กลับมาก็ได้ค่ะ
|
ประวัติการแก้ไข 2010-09-07 09:28:26 2010-09-07 09:30:57
 |
 |
 |
 |
Date :
2010-09-07 09:20:52 |
By :
blurEyes |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอขอบคุณทุกคนครับที่ช่วยเหลือ ตอนนี้ทำได้แล้วครับ
ก็เป็นอันว่า ทำการสมัครได้แล้ว
|
 |
 |
 |
 |
Date :
2010-09-08 03:13:17 |
By :
accio |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|