Accessing Content Page elements
- by Abdel Olakara
Hi all,
I am facing a strange problem.. may be i am overlooking something and not able to find the silly issue. Need your help! I have a Master page and a Content Page:
<form id="AccountForm" runat="server">
<div>
<asp:ContentPlaceHolder ID="MenuHolder" runat="server">
</asp:ContentPlaceHolder>
</div>
<hr />
<div>
<asp:ContentPlaceHolder ID="ContentHolder" runat="server">
</asp:ContentPlaceHolder>
</div>
And my content page has some form elements:
<asp:Content ID="Content3" ContentPlaceHolderID="ContentHolder" runat="server">
First Name: <asp:TextBox ID="fName" runat="server"></asp:TextBox> <br />
Middle Name: <asp:TextBox ID="mName" runat="server"></asp:TextBox> <br />
Family Name: <asp:TextBox ID="lName" runat="server"></asp:TextBox> <br />
Birthday: <asp:TextBox ID="birthday" runat="server"></asp:TextBox> <br />
Mobile Phone: <asp:TextBox ID="mobile" runat="server"></asp:TextBox> <br />
Alternate Phone: <asp:TextBox ID="phone" runat="server"></asp:TextBox> <br />
I also have the code for submit button in the content page where i try to retrieve the values from the form elements and persist it into DB. Here is the SubmitButton_Click code:
protected void SubmitButton_Click(object sender, EventArgs e)
{
log.Info("From Submit button: " + customerObject.first_name + " " + customerObject.family_name);
if (fName != null)
log.Info("First Name is not null");
log.Info("First Name:" + fName.Text);
log.Info("Middle Name:" + mName.Text);
log.Info("Family Name:" + fName.Text);
log.Info("Mobile:" + mobile.Text);
log.Info("Phone: " + phone.Text);
log.Info("Address:" + bAddressL1.Text + bAddressL2.Text);
Strangly.. i don't get any data that is filled into my text fields? Their objects are not null as well!! why is this behaviour happening? I am not trying to access elements in master page or other.. all the fields are in the content page.. only thing is there is no form element in the content page and the form element is in master page!
Thanks in advance for your suggestions and answers.
Abdel Raoof Olakara