You can access the Masterpage as a property on your current page. However, the controls on your master page are protected so you can't access them directly. But you can access them by using FindControl(string name). The code you need to use depends on if the control is inside or outside a content place holder.
// Gets a reference to a TextBox control inside a ContentPlaceHolder
ContentPlaceHolder mpContentPlaceHolder;
TextBox mpTextBox;
mpContentPlaceHolder =
(ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
if(mpContentPlaceHolder != null)
{
mpTextBox = (TextBox) mpContentPlaceHolder.FindControl("TextBox1");
if(mpTextBox != null)
{
mpTextBox.Text = "TextBox found!";
}
}
// Gets a reference to a Label control that is not in a
// ContentPlaceHolder control
Label mpLabel = (Label) Master.FindControl("masterPageLabel");
if(mpLabel != null)
{
Label1.Text = "Master page label = " + mpLabel.Text;
}
การทำระบบ member และ role นั้นง่ายเหมือนเกาตูด (ตัวเอง)
ซึ่งต้องใช้งานร่วมกันระหว่าง class user, member, role + aspnetdb + web.config
แทบไม่ต้องไปเขียนโค้ดเพื่อทำระบบ user เองเลย มัน build in มาให้อยู่แล้ว
ไม่ต้องกังวลเรื่องความปลอดภัย จะให้สิทธิ์เข้าถึงแค่ไหนก็กำหนด role
ใน aspnetdb แล้วเขียน web.config ให้มันจัดการ
ปล. ไม่ต้องสนใจเราหรอก เรารำคาญนายจะตาย
Date :
2013-07-25 10:37:28
By :
ห้ามตอบเกินวันละ 2 กระทู้
No. 10
Guest
ขอบคุณทุก ๆ คนที่ตอบกันมาน่ะค่ะ ทำได้แล้วค่ะ ^^
Date :
2013-07-25 10:43:04
By :
TBG'z
No. 11
Guest
Code
แทบไม่ต้องไปเขียนโค้ดเพื่อทำระบบ user เองเลย มัน build in มาให้อยู่แล้ว
ไม่ต้องกังวลเรื่องความปลอดภัย จะให้สิทธิ์เข้าถึงแค่ไหนก็กำหนด role
ใน aspnetdb แล้วเขียน web.config ให้มันจัดการ