Supp. Mobile Devices: +5000 worldwide • Hosted Sites: +8.000 • Served mobile pages & content: +1 Bill./month English | Deutsch 
- Back
Threads [ Previous | Next ]
Code behind
Code behind Anonymous 10/15/08 7:05 PM
RE: Code behind Anonymous 10/15/08 7:16 PM
RE: Code behind mcrabb 10/16/08 8:01 AM
RE: Code behind mcrabb 10/22/08 2:20 PM
Code behind | 10/15/08 7:05 PM
I'm trying to access controls in a form from my code behind file. I can't access it.

I tried

this.Form1.Form_Text1......

this.Form_Text1.........

this.name.text.........no luck. What am I missing? attached is my form.


<rb:Form ID="Form1" runat="server" CurCell="1, 4" Action = "mailto"
Method="GET">
<Rows>

<rb:NTableRow>
<Cells>
<rb:NTableCell runat="server" BGColor="">
<CellContent>
<rb:NTableCellRichText ID="NTableCellRichText1" runat="server">
<Text>
Name</Text>
</rb:NTableCellRichText>
</CellContent>
</rb:NTableCell>
<rb:NTableCell runat="server" BGColor="">
<CellContent>

<rb:Form_Text ID="Form_Text1" runat="server" Name="name">
</rb:Form_Text>

</CellContent>
</rb:NTableCell>
</Cells>
</rb:NTableRow>
<rb:NTableRow>
<Cells>
<rb:NTableCell runat="server" BGColor="">
<CellContent>
<rb:NTableCellRichText ID="NTableCellRichText2" runat="server">
<Text>
Email</Text>
</rb:NTableCellRichText>
</CellContent>
</rb:NTableCell>
<rb:NTableCell runat="server" BGColor="">
<CellContent>

<rb:Form_Text ID="Form_Text2" runat="server" Name="email">
</rb:Form_Text>

</CellContent>
</rb:NTableCell>
</Cells>
</rb:NTableRow>
<rb:NTableRow>
<Cells>
<rb:NTableCell runat="server" BGColor="">
<CellContent>
<rb:NTableCellRichText ID="NTableCellRichText3" runat="server">
<Text>
Message</Text>
</rb:NTableCellRichText>
</CellContent>
</rb:NTableCell>
<rb:NTableCell runat="server" BGColor="">
<CellContent>
<rb:Form_Text ID="Form_Text3" runat="server" Name="message" Rows="2">
</rb:Form_Text>
</CellContent>
</rb:NTableCell>
</Cells>
</rb:NTableRow>
<rb:NTableRow>
<Cells>
<rb:NTableCell runat="server" BGColor="">
<CellContent>
<rb:Form_Hidden ID="Form_Hidden1" runat="server" Name="successPage"
Value="ContactEmailSent.aspx">
</rb:Form_Hidden>
</CellContent>
</rb:NTableCell>
<rb:NTableCell runat="server" BGColor="">
<CellContent>
<rb:Form_Hidden ID="Form_Hidden2" runat="server" Name="errorPage"
Value="ContactEmailNotSent.aspx">
</rb:Form_Hidden>
</CellContent>
</rb:NTableCell>
</Cells>
</rb:NTableRow>
<rb:NTableRow>
<Cells>
<rb:NTableCell runat="server" BGColor="">
</rb:NTableCell>
<rb:NTableCell runat="server" BGColor="">
<CellContent>

<rb:Form_Hidden ID="Form_Hidden4" runat="server" Name="subject">
</rb:Form_Hidden>

</CellContent>
</rb:NTableCell>
</Cells>
</rb:NTableRow>
<rb:NTableRow>
<Cells>
<rb:NTableCell runat="server" BGColor="">
<CellContent>
<rb:Form_Hidden ID="Form_Hidden3" runat="server" Name="recipient"
Value="agoutham@mlspin.com">
</rb:Form_Hidden>
</CellContent>
</rb:NTableCell>
<rb:NTableCell runat="server" BGColor="">
<CellContent>
<rb:Form_Submit ID="Form_Submit1" runat="server" Value="Send">
</rb:Form_Submit>
</CellContent>
</rb:NTableCell>
</Cells>
</rb:NTableRow>
</Rows>
<Content>
&nbsp;
</Content>
<Headline>
<text>
By Email</text>
</Headline>
</rb:Form>
RE: Code behind | 10/15/08 7:16 PM as a reply to Anonymous.
Another related issue.......


Following code to add the hidden field inside the </form> tag fails. I get a .Net error message. What is the workaround for this? What am I missing in the code?

Thank you.

protected void Page_Load(object sender, EventArgs e)
{

HiddenField subject = new HiddenField();
subject.Value = "Message from mobile";
this.Form1.Controls.Add(subject);

}
RE: Code behind | 10/16/08 8:01 AM as a reply to Anonymous.
Hi,

to access a control inside a form you have to use this code:

if (Form1.FindControl("Form_Text1") != null)
((Form_Text)Form1.FindControl("Form_Text1")).Value = "hallo";


The code for the second problem has to look like this:

HiddenField subject = new HiddenField();
subject.Value = "Message from mobile";
NTableCellxx.Controls.Add(subject);

You have to render the control directly inside a NTableCell not in the form itself.

Regards,

Netbiscuits .NET Controls team
RE: Code behind | 10/22/08 2:20 PM as a reply to mcrabb.
Hi,

here is a thread which is on the same issue:

http://www.netbiscuits.com/messageboard/message_boards/message/84166

and regarding to this thread here's your code:


if (Request.HttpMethod == "POST")
{
if (!String.IsNullOrEmpty(Request["AgentID"]) && !String.IsNullOrEmpty(Request["Password"]))
{
Response.Redirect("~/ProcessLogin.aspx");
}

else
{
Text validationError = new Text();
validationError.BGColor = System.Drawing.Color.Red;
validationError.RichText = "Fill in all required fields (marked with a *)";
this.ValidationSummary.Controls.Add(validationError);
}
}


Next time use the search first ;)
Hope this will help you.

Regards

Netbiscuits .NET Controls Team