Laploy Web Board
Would you like to react to this message? Create an account in a few clicks or log in to continue.

สอบถามปัญหาครับ

2 posters

Go down

สอบถามปัญหาครับ Empty สอบถามปัญหาครับ

ตั้งหัวข้อ  newbieC# 21st June 2010, 4:35 pm

https://2img.net/r/ihimizer/img404/4638/piczr.png


สวัสดีครับอาจารย์ ขอโทษครับที่รบกวน

ผมเพิ่งหันมาจับ C# เขียน asp.net โดยเริ่มศึกษาได้ไม่กี่วันจากหนังสือตามท้องตลาดและหนังสือของ อาจารย์ แล้ว ก็มีงานด่วนมาให้ทำ คืองานของผมต้อง modify webboard ของ YAF (Yet Another forum.net)

แต่ผมติดและไม่เข้าใจตรงนี้ครับ

จากรูปครับ ผมแนบไว้ คือผมแก้ไขไฟล์ register.ascx.cs แล้วเซฟ มันจะไม่เปลียนแปลงอะไรเลย โปรแกรม สามารถทำงานได้ปกติ ไม่ว่าจะลบโค้ดภายในทิ้งหมด ก็ยังทำงานได้ปกติครับผมไม่เข้าใจ

นี่โค้ดครับ มี register.ascx กับ register.ascx.cx

register.ascx


<%@ Control language="c#" Codebehind="register.ascx.cs" AutoEventWireup="True" Inherits="yaf.pages.register" %>





<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Common" %>
<%@ Import Namespace="System.Data.Sql" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Register TagPrefix="yaf" Namespace="yaf.controls" Assembly="yaf" %>

<script runat="server">

/*
public void callin()
{

string connectionString = ConfigurationManager.ConnectionStrings["pttConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "INSERT INTO seperate (ref_company_id) VALUES ('" + DropDownList1.SelectedValue + "') ";
cmd.Connection = conn;
cmd.ExecuteNonQuery();



}

*/
public void Clikme()
{


}



protected void list_change(object sender, EventArgs e)
{


if (DropDownList1.SelectedValue != "0")
{

string connectionString = ConfigurationManager.ConnectionStrings["pttConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "SELECT agent_name,agent_id FROM agent where ref_company_id = '" + DropDownList1.SelectedValue + "' ";
cmd.Connection = conn;

//StringBuilder sb = new StringBuilder();
SqlDataReader reader = cmd.ExecuteReader();

/*
while (reader.Read())
{
sb.AppendFormat("company_name: {0}<BR/>", reader.GetString(0));
}
*/

DropDownList3.DataSource = reader;
DropDownList3.DataTextField = "agent_name";
DropDownList3.DataValueField = "agent_id";
DropDownList3.DataBind();
conn.Close();
DropDownList4_SelectedIndexChanged(sender, e);

}




}

protected void DropDownList4_SelectedIndexChanged(object sender, EventArgs e)
{
string connectionString = ConfigurationManager.ConnectionStrings["pttConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "SELECT line_name,line_id FROM line where ref_agent_id = '" + DropDownList3.SelectedValue + "' ";
cmd.Connection = conn;

StringBuilder sb = new StringBuilder();
SqlDataReader reader = cmd.ExecuteReader();

/*
while (reader.Read())
{
sb.AppendFormat("company_name: {0}<BR/>", reader.GetString(0));
}
*/

DropDownList4.DataSource = reader;
DropDownList4.DataTextField = "line_name";
DropDownList4.DataValueField = "line_id";
DropDownList4.DataBind();
conn.Close();
DropDownList5_SelectedIndexChanged(sender, e);

}
protected void on_line(object sender, EventArgs e)
{
DropDownList5_SelectedIndexChanged(sender, e);
}
protected void DropDownList5_SelectedIndexChanged(object sender, EventArgs e)
{
string connectionString = ConfigurationManager.ConnectionStrings["pttConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "SELECT position_name,position_id FROM position where ref_line_id = '" + DropDownList4.SelectedValue + "' ";
cmd.Connection = conn;

StringBuilder sb = new StringBuilder();
SqlDataReader reader = cmd.ExecuteReader();

/*
while (reader.Read())
{
sb.AppendFormat("company_name: {0}<BR/>", reader.GetString(0));
}
*/

DropDownList5.DataSource = reader;
DropDownList5.DataTextField = "position_name";
DropDownList4.DataValueField = "position_id";
DropDownList5.DataBind();
conn.Close();

}





protected void DropDownList3_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList4_SelectedIndexChanged(sender, e);
}



protected void Button1_Click(object sender, EventArgs e)
{
string connectionString = ConfigurationManager.ConnectionStrings["pttConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "INSERT INTO seperate (ref_company_id) VALUES ('1') ";
cmd.Connection = conn;
cmd.ExecuteNonQuery();
}
</script>
<yaf:PageLinks runat="server" id="PageLinks"/>


<table class="content" cellspacing=1 cellpadding=0 width="100%">
<tr>
<td class=header1 colspan="2"><%# GetText("title") %></td>
</tr>
<tr>
<td class=header2 colspan="2" align="middle"><%# GetText("details") %></td>
</tr>

<tr>


<td class=postheader>company :</td>
<td class=post>


<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="list_change" AppendDataBoundItems="true" DataValueField="company_id" DataTextField="company_name" DataSourceID="SqlDataSource1">

<asp:ListItem Value="0">---Please Choose---</asp:ListItem>



</asp:DropDownList>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:pttConnectionString %>"

SelectCommand="SELECT [company_name], [company_id] FROM [company] ORDER BY [company_id]"></asp:SqlDataSource>

</td>
</tr>
<tr>

<td class=postheader>agent (หน️่วยงาน️):</td>
<td class=post>




<asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList3_SelectedIndexChanged" >
</asp:DropDownList>



</td>
</tr>

<tr>

<td class=postheader>line(สายงาน️) :</td>
<td class=post>


<asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="True"
onselectedindexchanged="on_line">
</asp:DropDownList>











</td>
</tr>
<tr>
<td width="50%" class=postheader>Position(ตำ๠หน️่งงาน️):</td>
<td class=post>

<asp:DropDownList ID="DropDownList5" runat="server" >

</asp:DropDownList>

</td>
</tr>




<tr>
<td width="50%" class=postheader><%# GetText("username") %>:</td>
<td class=post>
<asp:TextBox id=UserName runat="server"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage='<%# GetText("need_username") %>' ControlToValidate="UserName" EnableClientScript="False"/>
</td>
</tr>


<tr>
<td class=postheader><%# GetText("password") %>:</td>
<td class=post>
<asp:TextBox id=Password runat="server" TextMode="Password"/>
<asp:RequiredFieldValidator runat="server" ErrorMessage='<%# GetText("need_password") %>' ControlToValidate="Password" EnableClientScript="False"/>
</td>
</tr>
<tr>
<td class=postheader><%# GetText("retype_password") %>:</td>
<td class=post>
<asp:TextBox id=Password2 runat="server" TextMode="Password"/>
<asp:CompareValidator runat="server" ErrorMessage='<%# GetText("need_match") %>' ControlToValidate="Password2" ControlToCompare="Password" EnableClientScript="False"/>
</td>
</tr>



<tr>
<!--
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" >
<asp:ListItem>African (Black)</asp:ListItem>
<asp:ListItem>Arab (Middle Eastern)</asp:ListItem>
<asp:ListItem>Asian</asp:ListItem>
<asp:ListItem>Caucasian (White)</asp:ListItem>
<asp:ListItem>Hispanic</asp:ListItem>
<asp:ListItem>Pacific Islander</asp:ListItem>
<asp:ListItem>Mixed</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:DropDownList>

-->

<td class=postheader><%# GetText("email") %>:</td>
<td class=post><asp:TextBox id=Email runat="server"/></td>
</tr>
<tr>
<td class=header2 colspan="2" align="middle"><%# GetText("profile") %></td>
</tr>
<tr>
<td class=postheader><%# GetText("location") %>:</td>
<td class=post><asp:TextBox id=Location runat="server"/></td>
</tr>
<tr>
<td class=postheader><%# GetText("homepage") %>:</td>
<td class=post><asp:TextBox id=HomePage runat="server"/></td>
</tr>
<tr>
<td class="header2" colspan="2" align="middle"><%# GetText("preferences") %></td>
</tr>
<tr>
<td class=postheader><%# GetText("timezone") %>:</td>
<td class=post><asp:DropDownList id=TimeZones runat="server" DataTextField="Name" DataValueField="Value"/></td>
</tr>

<tr>
<td align="middle" colspan="2" class=footer1>
<asp:Button id=ForumRegister cssclass="pbutton" runat="server" onclick="ForumRegister_Click" />
<asp:button id=cancel cssclass="pbutton" runat="server"/>

</td>
</tr>
</table>




<yaf:SmartScroller id="SmartScroller1" runat = "server" />


ส่วนนี่โค้ดครับที่บอก register.ascx.cs

โค้ด เนี่ยครับไม่ว่าผมจะทำอะไรมันก็ทำงานได้ปกติ เหมือนไม่เปลี่ยนแปลงค่าที่ผมแก้ไว้เลย ขอโทษที่รบกวนครับอาจารย์ ผมไม่ได้จริงๆมือใหม่ เลยขอสอบถามหน่อยครับ

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.Security;
using System.Globalization;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data.Common;

using System.Configuration;
using System.Web.Security;
using System.Web.Configuration;


namespace yaf.pages
{
/// <summary>
/// Summary description for register.
/// </summary>
public partial class register : ForumPage
{

public register()
: base("REGISTER")
{
}



protected void Page_Load(object sender, System.EventArgs e)
{
if (!User.CanLogin || BoardSettings.DisableRegistrations)
Data.AccessDenied();

if (!IsPostBack)
{
PageLinks.AddLink(BoardSettings.Name, Forum.GetLink(Pages.forum));
ForumRegister.Text = GetText("register");
cancel.Text = GetText("Cancel");

TimeZones.DataSource = Data.TimeZones();
DataBind();
TimeZones.Items.FindByValue("0").Selected = true;
}
}

private void cancel_Click(object sender, EventArgs e)
{
Forum.Redirect(Pages.forum);
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
cancel.Click += new EventHandler(cancel_Click);
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{

}
#endregion

static public string CreatePassword(int length)
{
string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
string res = "";
Random rnd = new Random();
while (0 < length--)
res += valid[rnd.Next(valid.Length)];
return res;
}

public static void insertGroup()
{


string connectionString = ConfigurationManager.ConnectionStrings["pttConnectionString"].ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "INSERT INTO seperate (ref_company_id) VALUES ('2') ";
http://cmd.CommandText = "INSERT INTO seperate (ref_company_id) VALUES ('" + DropDownList1.SelectedValue + "') ";
cmd.Connection = conn;
cmd.ExecuteNonQuery();




}

protected void ForumRegister_Click(object sender, System.EventArgs e)
{

if (Page.IsValid)
{
// trim username to disable duplicate names registration by employing leading spaces
UserName.Text = UserName.Text.Trim();

if (!Utils.IsValidEmail(Email.Text))
{
AddLoadMessage(GetText("BAD_EMAIL"));
return;
}

if (DB.user_find(PageBoardID, false, UserName.Text, Email.Text).Rows.Count > 0)
{
AddLoadMessage(GetText("ALREADY_REGISTERED"));
return;
}


DB.user_register(this, PageBoardID, UserName.Text, Password.Text, Email.Text, Location.Text, HomePage.Text, TimeZones.SelectedItem.Value, BoardSettings.EmailVerification, DropDownList1.SelectedValue);
// DropDownList3.SelectedValue, DropDownList4.SelectedValue, DropDownList5.SelectedValue
if (BoardSettings.EmailVerification)
{
Forum.Redirect(Pages.info, "i=3"); fgfg
}
else
{

// Grouptest.insertGroup();


// Forum.Redirect(Pages.login);
}
}


}


}

}


ด้วยความนับถือ
Newbie C#

newbieC#

จำนวนข้อความ : 2
Join date : 21/06/2010

ขึ้นไปข้างบน Go down

สอบถามปัญหาครับ Empty แบบนี้หรือป่าวครับ

ตั้งหัวข้อ  newbieC# 22nd June 2010, 2:55 pm

มันเกิดจาก .dll มันไม่ update หรือป่าวครับ มันถึงไม่มีผลไม่ว่าเราจะแก้โค้ดอะไร แล้วต้องมีวิธีการอย่างไรให้มันอัพเดทหรือครับ Surprised

newbieC#

จำนวนข้อความ : 2
Join date : 21/06/2010

ขึ้นไปข้างบน Go down

สอบถามปัญหาครับ Empty deployment

ตั้งหัวข้อ  Admin 5th July 2010, 12:19 pm

ขอโทษที่ตอบช้านะครับ ปัญหาของคุณเกิดจากแอสเซมบลีไม่อัพเดต โปรดทราบว่าเมื่อคุณเปลี่ยนแปลงซอร์สโค้ด และนำซอร์สโค้ดไปไว้ที่เซอฟเวอร์ ผลลัพธ์จะไม่มีอะไรเปลี่ยนแปลง เพราะซอฟเวอร์ไม่ได้รับรู้หรือสนใจซอร์สโค้ด มันสนใจแต่แอสเซมบลีเท่านั้น

สิ่งที่คุณต้องทำคือทำความเข้าใจเรื่อง deployment ให้ดี พูดย่อๆ deployment คือการ build แล้วนำ aspx และแอสเซมบลีไปใส่ในเซอฟเวอร์ให้ถูกที่ ปรกติ MSVS จะทำให้ได้โดยอัตโนมัติอยู่แล้ว ข้อสำคัญตือต้องให้แน่ใจว่าคุณได้ลบของเก่าในเซอเวอร์ทิ้งเสียก่อน

Admin
Admin

จำนวนข้อความ : 215
Join date : 17/12/2009

http://laploy.forumotion.com

ขึ้นไปข้างบน Go down

ขึ้นไปข้างบน


 
Permissions in this forum:
คุณไม่สามารถพิมพ์ตอบ