Supp. Mobile Devices: +5000 worldwide - Hosted Sites: +8.000 - Served mobile pages & content: +1 Bill./month English | Deutsch 
- Back
Threads [ Previous | Next ]
Forms
Forms Anonymous 10/10/08 8:04 PM
RE: Forms webmaster 10/13/08 3:12 PM
RE: Forms mcrabb 10/15/08 8:32 AM
RE: Forms Anonymous 10/15/08 12:30 PM
RE: Forms Anonymous 10/15/08 7:12 PM
RE: Forms mcrabb 10/16/08 8:04 AM
RE: Forms Anonymous 10/21/08 1:36 PM
RE: Forms mcrabb 10/22/08 1:26 PM
RE: Forms Anonymous 11/12/08 3:44 PM
RE: Forms nbcommunity 11/14/08 8:26 AM
Forms | 10/10/08 8:04 PM
Hi,

I submitted a form with a few input controls (created using .Net biscuit controls).

The following code to collect form variables in the post page is not working

if(!string.IsNullOrEmpty(Request["day"]))
Text2.RichText = "day: " + Request["day"];
RE: Forms | 10/13/08 3:12 PM as a reply to Anonymous.
You must not put a “if (IsPostBack)” in the page_load area. We have no way to handle this.

If you want to do something similar try:


if (Request.HttpMethod == "POST")
{
[…]
}


The rest is working properly.


If it does not work for you please post your complete source code because we do not
know how you post the data.

Regards,
Webmaster
RE: Forms | 10/15/08 8:32 AM as a reply to Anonymous.
Hi,

I read your code and found your fault.
you have to set the name of the rb:Form_Text.
The id is only for accessing the control from the code behind
and the name sets the request variable.

Regards

Netbiscuits .NET Controls Team
RE: Forms | 10/15/08 12:30 PM as a reply to mcrabb.
Thank you. I figured that out. Appreciate your prompt response.
RE: Forms | 10/15/08 7:12 PM as a reply to Anonymous.
Following code does not add hidden field inside the </form> tag. I get a .Net error message saying "Hidden fields should be enclosed inside a form tag". What is the workaround for this?

Thanks


protected void Page_Load(object sender, EventArgs e)
{

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

}
RE: Forms | 10/16/08 8:04 AM as a reply to Anonymous.
Hi,

to add a control to a form via code behind you have to use this code:

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

Note: render the control directly inside a NTableCell not in the form itself.

Regards,

Netbiscuits .NET Controls team
RE: Forms | 10/21/08 1:36 PM as a reply to mcrabb.
Based on your feeback, I tried the following code.
Here's my form for your review.

<rblaceHolder ID="PlaceHolder1" runat="server">
</rblaceHolder>

<rb:Form ID="Form1" runat="server" Method = "POST">
<Rows>
</Rows>
<Content>
<rb:Form_Text ID="Form_Text2" runat="server" >
</rb:Form_Text>
<rb:Form_Submit ID="Form_Submit1" runat="server" Name="submit" Value="submit">
</rb:Form_Submit>
</Content>
</rb:Form>


When I enter value into the text field and submit, the following code (in code behind on page load) does not work. I could not read the text field. What am I missing?

if (Form1.FindControl("Form_Text2") != null)
{

if (!string.IsNullOrEmpty(((Form_Text)Form1.FindControl("Form_Text2")).Value))
{

Text validationError = new Text();
validationError.BGColor = System.Drawing.Color.Red;
validationError.RichText = "im here";
// validationError.RichText = ((Form_Text)Form1.FindControl("Form_Text2")).Value;

this.PlaceHolder1.Controls.Add(validationError);
}
else
{
Text validationError = new Text();
validationError.BGColor = System.Drawing.Color.Red;
validationError.RichText = "im here. Could not read the text field";
// validationError.RichText = ((Form_Text)Form1.FindControl("Form_Text2")).Value;

this.PlaceHolder1.Controls.Add(validationError);
}
}

I'm able to set the value though by using the following code.

//if (Form1.FindControl("Form_Text2") != null)
// ((Form_Text)Form1.FindControl("Form_Text2")).Value = "hello";
RE: Forms | 10/22/08 1:26 PM as a reply to Anonymous.
Hi,

your code has to look like this:

<rblaceHolder ID="PlaceHolder1" runat="server">
</rblaceHolder>

<rb:Form ID="Form1" runat="server" Method ="POST">
<Rows>
</Rows>
<Content>
<rb:Form_Text ID="Form_Text2" Name="Form_Text2" runat="server" >
</rb:Form_Text>
<rb:Form_Submit ID="Form_Submit1" runat="server" Name="submit" Value="submit">
</rb:Form_Submit>
</Content>
</rb:Form>

Note: You have to enter the name of the Form_Text element for using it.

And here is your code behind:


if (Request.HttpMethod == "POST")
{
Text validationError = new Text();
validationError.BGColor = System.Drawing.Color.Red;

if (!string.IsNullOrEmpty(Request["Form_Text2"]))
{
validationError.RichText = "im here";
// validationError.RichText = ((Form_Text)Form1.FindControl("Form_Text2")).Value;
}
else
{
validationError.RichText = "im here. Could not read the text field or it is empty";
// validationError.RichText = ((Form_Text)Form1.FindControl("Form_Text2")).Value;
}

this.PlaceHolder1.Controls.Add(validationError);

}

You must not access the value of the element itself, you have to access the posted data.
Every element stores its data in a request variable named as itself.
From this variable you can read the value.

Regards,

Netbiscuits .NET Controls team
RE: Forms | 11/12/08 3:44 PM as a reply to mcrabb.
I have a form and I'd like to simply display a star (or message) next to a field if it does not validate on submit.

Should something like this work? Here are relevant code samples:

Text firstNameStar = new Text();
firstNameStar.Color = System.Drawing.Color.Red;


if (string.IsNullOrEmpty(Request["txtFirstName"]))
{
firstNameStar.RichText = "*";
populated = false;
}


netbiscuits.PlaceHolder PlaceHolder3 = new netbiscuits.PlaceHolder();
PlaceHolder3.Controls.Add(firstNameStar);
NTableCell2.Controls.Add(PlaceHolder3);

I can't get it to show up.
RE: Forms | 11/14/08 8:26 AM as a reply to Anonymous.
We looked through your code and this is how it has to look like:

Form:

<rb:form runat="server" Method="POST" ID="Form1">
<Rows>
<rb:NTableRow ID="NTableRow1" runat="server">
<Cells>
<rb:NTableCell ID="NTableCell1" runat="server">
<CellContent>
<rb:form_text ID="txtFirstName" Name="txtFirstName" runat="server" />
<rb:NTableCellRichText ID="RichText1" runat="server" />
</CellContent>
</rb:NTableCell>
</Cells>
</rb:NTableRow>
<rb:NTableRow ID="NTableRow2" runat="server">
<Cells>
<rb:NTableCell ID="NTableCell2" runat="server">
<CellContent>
<rb:form_submit Name="submit" runat="server" Value="submit" />
</CellContent>
</rb:NTableCell>
</Cells>
</rb:NTableRow>
</Rows>
</rb:form>

Code behind (in PageLoad):

if (Request.HttpMethod == "POST")
{
if (string.IsNullOrEmpty(Request["txtFirstName"]))
{
if (Form1.FindControl("RichText1") != null)
{
NTableCellRichText Cell1 = (NTableCellRichText)Form1.FindControl("RichText1");
Cell1.TextColor = System.Drawing.Color.Red;
Cell1.Text = "*";
}
}
}