| Suresh Nair |
-- Moved from [aspngfreeforall] to [aspngmob] by Marcie Jones <Click here to reveal e-mail address> --
Hi guys!
I have some validators added to my mobile form, and under the button(<mobile:Command> Like a submit button it has to post my variables to the next page) click event, I check for the page.IsValid first and then set my Form action to the next page I would want to go.
The strange thing here is, the validations works perfectly, But then i need to make 2 clicks on the button to traverse to the next page. To be more precise, on the 1st click it checks and validates all the controls that i want to validate and on the 2nd click it takes me to the next page. Now i have no clue about this at all.
Let me know if you guys out there have any any any clue!
Thanks SN
|
|
| |
| |
| Anil John |
Suresh,
Please post the code for your page...
In addition, how are you testing your pages? Using IE or with an emulator?
Anil
---------- Original Message ---------------------------------- From: Suresh Nair <Click here to reveal e-mail address> Reply-To: "aspngmob" <Click here to reveal e-mail address> Date: Mon, 1 Jul 2002 09:50:15 -0400
-- Moved from [aspngfreeforall] to [aspngmob] by Marcie Jones <Click here to reveal e-mail address> --
Hi guys!
I have some validators added to my mobile form, and under the button(<mobile:Command> Like a submit button it has to post my variables to the next page) click event, I check for the page.IsValid first and then set my Form action to the next page I would want to go.
The strange thing here is, the validations works perfectly, But then i need to make 2 clicks on the button to traverse to the next page. To be more precise, on the 1st click it checks and validates all the controls that i want to validate and on the 2nd click it takes me to the next page. Now i have no clue about this at all.
Let me know if you guys out there have any any any clue!
Thanks SN | [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
-- -- Anil John - http://LearnMobile.net -- #1 .net Mobile & Wireless Resource -- Connect with .net - Anytime. Anywhere. --
|
|
| |
|
| |
| Suresh Nair |
My .cs file !:
if (Page.IsValid && year.Text != "") { try { System.DateTime dtn = DateTime.Now; string fd = month.Text +"/" +date.Text +"/" +year.Text +" 00:00:00 AM"; System.DateTime dt = System.DateTime.Parse(fd); Response.Write("is" +dt); if (dt > dtn) { error.Text= "please check the date u entered"; error.Visible = true; } registration.Action = "sam_welcome.aspx"; } catch { error.Text = "The date entered should be a valid date"; error.Visible = true; } } else { error.Text = "Please enter the year"; error.Visible=true; }
Just the mobile:command info from the aspx file!
<mobile:Command id="register" OnClick ="checkForm" runat="server">Register</mobile:Command>
Thanks SN
-----Original Message----- From: Anil John [mailto:Click here to reveal e-mail address] Sent: Monday, July 01, 2002 1:05 PM To: aspngmob Subject: [aspngmob] Re: Field Validators & <mobile:Command>
Suresh,
Please post the code for your page...
In addition, how are you testing your pages? Using IE or with an emulator?
Anil
---------- Original Message ---------------------------------- From: Suresh Nair <Click here to reveal e-mail address> Reply-To: "aspngmob" <Click here to reveal e-mail address> Date: Mon, 1 Jul 2002 09:50:15 -0400
-- Moved from [aspngfreeforall] to [aspngmob] by Marcie Jones <Click here to reveal e-mail address> --
Hi guys!
I have some validators added to my mobile form, and under the button(<mobile:Command> Like a submit button it has to post my variables to the next page) click event, I check for the page.IsValid first and then set my Form action to the next page I would want to go.
The strange thing here is, the validations works perfectly, But then i need to make 2 clicks on the button to traverse to the next page. To be more precise, on the 1st click it checks and validates all the controls that i want to validate and on the 2nd click it takes me to the next page. Now i have no clue about this at all.
Let me know if you guys out there have any any any clue!
Thanks SN | [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
-- -- Anil John - http://LearnMobile.net -- #1 .net Mobile & Wireless Resource -- Connect with .net - Anytime. Anywhere. --
| [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
|
|
| |
|
| |
| Suresh Nair |
Right now i have it testing on IE. I have an Access emulator, but then my application right now has to go through a proxy server, so not too sure if we can set up proxy setting for the emulator
Thanks SN
-----Original Message----- From: Anil John [mailto:Click here to reveal e-mail address] Sent: Monday, July 01, 2002 1:05 PM To: aspngmob Subject: [aspngmob] Re: Field Validators & <mobile:Command>
Suresh,
Please post the code for your page...
In addition, how are you testing your pages? Using IE or with an emulator?
Anil
---------- Original Message ---------------------------------- From: Suresh Nair <Click here to reveal e-mail address> Reply-To: "aspngmob" <Click here to reveal e-mail address> Date: Mon, 1 Jul 2002 09:50:15 -0400
-- Moved from [aspngfreeforall] to [aspngmob] by Marcie Jones <Click here to reveal e-mail address> --
Hi guys!
I have some validators added to my mobile form, and under the button(<mobile:Command> Like a submit button it has to post my variables to the next page) click event, I check for the page.IsValid first and then set my Form action to the next page I would want to go.
The strange thing here is, the validations works perfectly, But then i need to make 2 clicks on the button to traverse to the next page. To be more precise, on the 1st click it checks and validates all the controls that i want to validate and on the 2nd click it takes me to the next page. Now i have no clue about this at all.
Let me know if you guys out there have any any any clue!
Thanks SN | [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
-- -- Anil John - http://LearnMobile.net -- #1 .net Mobile & Wireless Resource -- Connect with .net - Anytime. Anywhere. --
| [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
|
|
| |
|
| |
| Anil John |
Suresh,
Please post the complete aspx page and the code behind so that I can replicate the problem (Copy and paste in VS.Net and run the code). The information that you've provided is incomplete.
Some questions as well:
Is there a particular reason that you are using response.write in your mobile page rather than setting the value equal to a label control?
What is the error control? Where are the values of month, year, date coming from?
Anil
---------- Original Message ---------------------------------- From: Suresh Nair <Click here to reveal e-mail address> Reply-To: "aspngmob" <Click here to reveal e-mail address> Date: Mon, 1 Jul 2002 13:03:40 -0400
My .cs file !:
if (Page.IsValid && year.Text != "") { try { System.DateTime dtn = DateTime.Now; string fd = month.Text +"/" +date.Text +"/" +year.Text +" 00:00:00 AM"; System.DateTime dt = System.DateTime.Parse(fd); Response.Write("is" +dt); if (dt > dtn) { error.Text= "please check the date u entered"; error.Visible = true; } registration.Action = "sam_welcome.aspx"; } catch { error.Text = "The date entered should be a valid date"; error.Visible = true; } } else { error.Text = "Please enter the year"; error.Visible=true; }
Just the mobile:command info from the aspx file!
<mobile:Command id="register" OnClick ="checkForm" runat="server">Register</mobile:Command>
Thanks SN
-----Original Message----- From: Anil John [mailto:Click here to reveal e-mail address] Sent: Monday, July 01, 2002 1:05 PM To: aspngmob Subject: [aspngmob] Re: Field Validators & <mobile:Command>
Suresh,
Please post the code for your page...
In addition, how are you testing your pages? Using IE or with an emulator?
Anil
---------- Original Message ---------------------------------- From: Suresh Nair <Click here to reveal e-mail address> Reply-To: "aspngmob" <Click here to reveal e-mail address> Date: Mon, 1 Jul 2002 09:50:15 -0400
-- Moved from [aspngfreeforall] to [aspngmob] by Marcie Jones <Click here to reveal e-mail address> --
Hi guys!
I have some validators added to my mobile form, and under the button(<mobile:Command> Like a submit button it has to post my variables to the next page) click event, I check for the page.IsValid first and then set my Form action to the next page I would want to go.
The strange thing here is, the validations works perfectly, But then i need to make 2 clicks on the button to traverse to the next page. To be more precise, on the 1st click it checks and validates all the controls that i want to validate and on the 2nd click it takes me to the next page. Now i have no clue about this at all.
Let me know if you guys out there have any any any clue!
Thanks SN | [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
-- -- Anil John - http://LearnMobile.net -- #1 .net Mobile & Wireless Resource -- Connect with .net - Anytime. Anywhere. --
| [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
| [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
|
|
| |
|
| |
| Suresh Nair |
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" %> <%@ Page language="c#" Codebehind="sam_registration.aspx.cs" Inherits="SAMPRO.sam_registration" AutoEventWireup="false" %> <meta content="Microsoft Visual Studio 7.0" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="http://schemas.microsoft.com/Mobile/Page" name="vs_targetSchema"> <body Xmlns:mobile="http://schemas.microsoft.com/Mobile/WebForm"> <mobile:form id="registration" OnLoad="check" BackColor="#E0E0E0" Method="Get" runat="server"> <mobile:Label id="heading" runat="server" ForeColor="#FF3333" Alignment="Center" Font-Bold="True">SAM Registration</mobile:Label> <BR> <mobile:Label id="error" runat="server" ForeColor="Red" Alignment="Center" Font-Bold="True" Visible="False"></mobile:Label> <BR> <mobile:Label id="text" runat="server" Alignment="Center" OnInit="fillText">text</mobile:Label> <BR> <mobile:Label id="nameL" runat="server" Alignment="Left">Name:</mobile:Label> <mobile:TextBox id="nameT" runat="server" Size="10"></mobile:TextBox> <mobile:RequiredFieldValidator id="forUser" runat="server" ControlToValidate="nameT" ErrorMessage="Enter Username">Enter Username</mobile:RequiredFieldValidator> <mobile:Label id="lnameL" runat="server" Alignment="Left">Last Name:</mobile:Label> <mobile:TextBox id="lnameT" runat="server" Size="10"></mobile:TextBox> <mobile:RequiredFieldValidator id="forLname" runat="server" ControlToValidate="lnameT" ErrorMessage="Enter Lastname">Enter Lastname</mobile:RequiredFieldValidator> <mobile:Label id="sexL" runat="server" Alignment="Left">Sex:</mobile:Label> <mobile:SelectionList id="sex" runat="server" Alignment="Left" SelectType="Radio"> <Item Value="1" Selected="True" Text="Male"></Item> <Item Value="2" Text="Female"></Item> </mobile:SelectionList> <mobile:Label id="BD" runat="server">Birth Date:</mobile:Label> <mobile:TextBox id="month" Alignment="Left" Size="2" MaxLength="2" Runat="server"></mobile:TextBox> <mobile:RangeValidator id="forMonth" runat="server" ControlToValidate="month" ErrorMessage="Invalid Month" MaximumValue="12" MinimumValue="1">Invalid Month</mobile:RangeValidator> <mobile:TextBox id="date" Alignment="Left" Size="2" MaxLength="2" Runat="server"></mobile:TextBox> <mobile:RangeValidator id="forDate" runat="server" ControlToValidate="date" ErrorMessage="Invalid Date" MaximumValue="31" MinimumValue="1">Invalid Date</mobile:RangeValidator> <mobile:TextBox id="year" Alignment="Left" Size="4" MaxLength="4" Runat="server"></mobile:TextBox> <mobile:RegularExpressionValidator id="forYear" runat="server" ControlToValidate="year" ErrorMessage="Enter a valid year" ValidationExpression="\d{4}">Enter a valid year</mobile:RegularExpressionValidator> <mobile:Label id="professionL" runat="server">Profession:</mobile:Label> <mobile:SelectionList id="profession" runat="server" Visible="True" OnInit="callProfessionFill"></mobile:SelectionList> <mobile:Label id="cargoL" runat="server">Cargo:</mobile:Label> <mobile:SelectionList id="cargo" runat="server" Visible="True" OnInit="callCargoFill"></mobile:SelectionList> <mobile:Label id="pinL" runat="server">PIN:</mobile:Label> <mobile:TextBox id="pinT" runat="server" Size="10"></mobile:TextBox> <mobile:RequiredFieldValidator id="forPin" runat="server" ControlToValidate="pinT" ErrorMessage="Enter your PIN">Enter your PIN</mobile:RequiredFieldValidator> <mobile:Label id="msisdn" runat="server">MSISDN</mobile:Label> <mobile:TextBox id="msisdnT" runat="server"></mobile:TextBox> <mobile:Label id="email" runat="server">Email</mobile:Label> <mobile:TextBox id="emailT" runat="server"></mobile:TextBox> <mobile:Label id="ip" runat="server">IP</mobile:Label> <mobile:TextBox id="ipT" runat="server"></mobile:TextBox> <BR> <mobile:Command id="register" OnClick="checkForm" runat="server">Register</mobile:Command> </mobile:form> </body>
You probably will get the answers to all ur questions on seeing the above code!
My .CS file Looks like this
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.Mobile; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.MobileControls; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using Sam.Services.Subscription.DemographicOption;
namespace SAMPRO { /// <summary> /// Summary description for MobileWebForm1. /// </summary> public class sam_registration : System.Web.UI.MobileControls.MobilePage { protected System.Web.UI.MobileControls.SelectionList sex; protected System.Web.UI.MobileControls.TextBox month; protected System.Web.UI.MobileControls.TextBox date; protected System.Web.UI.MobileControls.TextBox year; protected System.Web.UI.MobileControls.Command register; protected System.Web.UI.MobileControls.Label error; protected System.Web.UI.MobileControls.Label heading; protected System.Web.UI.MobileControls.Label text; protected System.Web.UI.MobileControls.Label nameL; protected System.Web.UI.MobileControls.TextBox nameT; protected System.Web.UI.MobileControls.Label lnameL; protected System.Web.UI.MobileControls.TextBox lnameT; protected System.Web.UI.MobileControls.Label sexL; protected System.Web.UI.MobileControls.Label BD; protected System.Web.UI.MobileControls.Label professionL; protected System.Web.UI.MobileControls.Label cargoL; protected System.Web.UI.MobileControls.Label pinL; protected System.Web.UI.MobileControls.TextBox pinT; protected System.Web.UI.MobileControls.Label msisdn; protected System.Web.UI.MobileControls.TextBox msisdnT; protected System.Web.UI.MobileControls.Label email; protected System.Web.UI.MobileControls.TextBox emailT; protected System.Web.UI.MobileControls.Label ip; protected System.Web.UI.MobileControls.TextBox ipT; protected System.Web.UI.MobileControls.SelectionList profession; protected System.Web.UI.MobileControls.SelectionList cargo; protected System.Web.UI.MobileControls.RangeValidator forMonth; protected System.Web.UI.MobileControls.RangeValidator forDate; protected System.Web.UI.MobileControls.RequiredFieldValidator forUser; protected System.Web.UI.MobileControls.RequiredFieldValidator forLname; protected System.Web.UI.MobileControls.RequiredFieldValidator forPin; protected System.Web.UI.MobileControls.RegularExpressionValidator forYear; protected System.Web.UI.MobileControls.Form registration;
private void Page_Load(object sender, System.EventArgs e) { }
#region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // 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
public void checkForm(object sender, EventArgs e) { if (Page.IsValid && year.Text != "") { try { System.DateTime dtn = DateTime.Now; string fd = month.Text +"/" +date.Text +"/" +year.Text +" 00:00:00 AM"; System.DateTime dt = System.DateTime.Parse(fd); Response.Write("is" +dt); if (dt > dtn) { error.Text= "please check the date u entered"; error.Visible = true; } registration.Action = "sam_welcome.aspx"; } catch { error.Text = "The date entered should be a valid date"; error.Visible = true; } } else { error.Text = "Please enter the year"; error.Visible=true; } }
// /// <summary> /// this function is called when the label text gets // initialised. Its basically to show up with a text message /// </summary> /// <param name="sender"></param> /// <param name="e"></param>
public void fillText(object sender, EventArgs e) { text.Text = "Welcome to carrier's service, please enter the following information to create you account and allow our system provide you with the benefits"; }
/// <summary> /// This function is called when the form is loaded, It basically /// checks for the flag value in the URL, while called. /// If flag = 1 then we know there was an error while we try to /// register the user(the CreateUser method returns a value 0) /// /// If flag = 2 then we know that the user failed to enter the /// all the required fields. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void check(object sender, EventArgs e) { string flag = Request.QueryString["flag"]; if (flag == "1") { error.Text= "There was an error while registering you!"; error.Visible = true; } else if (flag=="2") { error.Text= "Please enter the complete information"; error.Visible = true; } else if (flag=="3") { error.Text= "Please check the year you entered"; error.Visible = true; } } /// <summary> /// This function is called when the selection list(profession) /// is initialized. /// /// Library used: Sam.Services.Subscription.DemographicOption /// Class used: DemographicOptionClient() /// Method used: GetDemographicOptionClient() /// Parameters: /// 1)demoSettingId:Is always 1 when used for profession type:int. /// /// Control used: Selectionlist, Id = profession. /// Datasource property= The dataset(rows) returned by the method GetDemographicOptionClient() /// DataTextField property = The coloumn demographicOptionName. /// DataValueField property = The coloumn demographicOptionId. /// /// Purpose: This approach enables to add a new profession with /// out changing the code. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void callProfessionFill(object sender, EventArgs e) { int demoSettingId = 1; try { DemographicOptionClient d = new DemographicOptionClient(); DemographicOptionDataSet ds = d.GetDemographicOptionsBySettingId(demoSettingId); profession.DataSource = ds.DemographicSettingsOptions.Rows; profession.DataTextField = "demographicOptionName"; profession.DataValueField = "demographicOptionId"; profession.DataBind(); } catch (Exception err) { error.Text = err.Message; error.Visible = true; return; } }
/// <summary> /// This function is called when the selection list(cargo) /// is initialized. /// /// Library used: Sam.Services.Subscription.DemographicOption /// Class used: DemographicOptionClient() /// Method used: GetDemographicOptionClient() /// Parameters: /// 1)demoSettingId:Is always 2 when used for cargo, type: int. /// /// Control used: Selectionlist, Id = cargo. /// Datasource property= The dataset(rows) returned by the method GetDemographicOptionClient() /// DataTextField property = The coloumn demographicOptionName. /// DataValueField property = The coloumn demographicOptionId. /// /// Purpose: This approach enables to add a new cargo without /// changing the code. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void callCargoFill(object sender, EventArgs e) { int demoSettingId = 2; try { DemographicOptionClient d = new DemographicOptionClient(); DemographicOptionDataSet ds = d.GetDemographicOptionsBySettingId(demoSettingId); cargo.DataSource = ds.DemographicSettingsOptions.Rows; cargo.DataTextField = "demographicOptionName"; cargo.DataValueField = "demographicOptionId"; cargo.DataBind(); } catch (Exception err) { error.Text = err.Message ; error.Visible = true; return; } }
} }
SN
-----Original Message----- From: Anil John [mailto:Click here to reveal e-mail address] Sent: Monday, July 01, 2002 4:29 PM To: aspngmob Subject: [aspngmob] Re: Field Validators & <mobile:Command>
Suresh,
Please post the complete aspx page and the code behind so that I can replicate the problem (Copy and paste in VS.Net and run the code). The information that you've provided is incomplete.
Some questions as well:
Is there a particular reason that you are using response.write in your mobile page rather than setting the value equal to a label control?
What is the error control? Where are the values of month, year, date coming from?
Anil
---------- Original Message ---------------------------------- From: Suresh Nair <Click here to reveal e-mail address> Reply-To: "aspngmob" <Click here to reveal e-mail address> Date: Mon, 1 Jul 2002 13:03:40 -0400
My .cs file !:
if (Page.IsValid && year.Text != "") { try { System.DateTime dtn = DateTime.Now; string fd = month.Text +"/" +date.Text +"/" +year.Text +" 00:00:00 AM"; System.DateTime dt = System.DateTime.Parse(fd); Response.Write("is" +dt); if (dt > dtn) { error.Text= "please check the date u entered"; error.Visible = true; } registration.Action = "sam_welcome.aspx"; } catch { error.Text = "The date entered should be a valid date"; error.Visible = true; } } else { error.Text = "Please enter the year"; error.Visible=true; }
Just the mobile:command info from the aspx file!
<mobile:Command id="register" OnClick ="checkForm" runat="server">Register</mobile:Command>
Thanks SN
-----Original Message----- From: Anil John [mailto:Click here to reveal e-mail address] Sent: Monday, July 01, 2002 1:05 PM To: aspngmob Subject: [aspngmob] Re: Field Validators & <mobile:Command>
Suresh,
Please post the code for your page...
In addition, how are you testing your pages? Using IE or with an emulator?
Anil
---------- Original Message ---------------------------------- From: Suresh Nair <Click here to reveal e-mail address> Reply-To: "aspngmob" <Click here to reveal e-mail address> Date: Mon, 1 Jul 2002 09:50:15 -0400
-- Moved from [aspngfreeforall] to [aspngmob] by Marcie Jones <Click here to reveal e-mail address> --
Hi guys!
I have some validators added to my mobile form, and under the button(<mobile:Command> Like a submit button it has to post my variables to the next page) click event, I check for the page.IsValid first and then set my Form action to the next page I would want to go.
The strange thing here is, the validations works perfectly, But then i need to make 2 clicks on the button to traverse to the next page. To be more precise, on the 1st click it checks and validates all the controls that i want to validate and on the 2nd click it takes me to the next page. Now i have no clue about this at all.
Let me know if you guys out there have any any any clue!
Thanks SN | [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
-- -- Anil John - http://LearnMobile.net -- #1 .net Mobile & Wireless Resource -- Connect with .net - Anytime. Anywhere. --
| [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
| [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
| [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
|
|
| |
|
| |
| Anil John |
After playing around with this, I have some comments and questions for you..
What is your target device? From the Html constructs that you have within this form, I am assuming that it is probably a pocket pc device... If so why aren't you using a regular asp.net form?
Why are you not databinding to a dropdown list(s) on page load (You seem to be using a OnInit fuctions to prefill instead)
The reason that you are having to click twice is because you have not wired up the Submit button to the validate function. Instead you are wiring it up to a custom Onclick event instead!
It really looks as though this was not natively created mobile web form but is instead an existing asp or asp.net page that you are trying to make into a mobile page..
I would suggest that you look at the best practices for databinding, validation and rewrite this page from scratch if the intent is to make this a cross-device mobile page.
Anil
-----Original Message----- From: Suresh Nair [mailto:Click here to reveal e-mail address] Sent: Monday, July 01, 2002 4:41 PM To: aspngmob Subject: [aspngmob] Re: Field Validators & <mobile:Command>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" %> <%@ Page language="c#" Codebehind="sam_registration.aspx.cs" Inherits="SAMPRO.sam_registration" AutoEventWireup="false" %> <meta content="Microsoft Visual Studio 7.0" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="http://schemas.microsoft.com/Mobile/Page" name="vs_targetSchema"> <body Xmlns:mobile="http://schemas.microsoft.com/Mobile/WebForm"> <mobile:form id="registration" OnLoad="check" BackColor="#E0E0E0" Method="Get" runat="server"> <mobile:Label id="heading" runat="server" ForeColor="#FF3333" Alignment="Center" Font-Bold="True">SAM Registration</mobile:Label> <BR> <mobile:Label id="error" runat="server" ForeColor="Red" Alignment="Center" Font-Bold="True" Visible="False"></mobile:Label> <BR> <mobile:Label id="text" runat="server" Alignment="Center" OnInit="fillText">text</mobile:Label> <BR> <mobile:Label id="nameL" runat="server" Alignment="Left">Name:</mobile:Label> <mobile:TextBox id="nameT" runat="server" Size="10"></mobile:TextBox> <mobile:RequiredFieldValidator id="forUser" runat="server" ControlToValidate="nameT" ErrorMessage="Enter Username">Enter Username</mobile:RequiredFieldValidator> <mobile:Label id="lnameL" runat="server" Alignment="Left">Last Name:</mobile:Label> <mobile:TextBox id="lnameT" runat="server" Size="10"></mobile:TextBox> <mobile:RequiredFieldValidator id="forLname" runat="server" ControlToValidate="lnameT" ErrorMessage="Enter Lastname">Enter Lastname</mobile:RequiredFieldValidator> <mobile:Label id="sexL" runat="server" Alignment="Left">Sex:</mobile:Label> <mobile:SelectionList id="sex" runat="server" Alignment="Left" SelectType="Radio"> <Item Value="1" Selected="True" Text="Male"></Item> <Item Value="2" Text="Female"></Item> </mobile:SelectionList> <mobile:Label id="BD" runat="server">Birth Date:</mobile:Label> <mobile:TextBox id="month" Alignment="Left" Size="2" MaxLength="2" Runat="server"></mobile:TextBox> <mobile:RangeValidator id="forMonth" runat="server" ControlToValidate="month" ErrorMessage="Invalid Month" MaximumValue="12" MinimumValue="1">Invalid Month</mobile:RangeValidator> <mobile:TextBox id="date" Alignment="Left" Size="2" MaxLength="2" Runat="server"></mobile:TextBox> <mobile:RangeValidator id="forDate" runat="server" ControlToValidate="date" ErrorMessage="Invalid Date" MaximumValue="31" MinimumValue="1">Invalid Date</mobile:RangeValidator> <mobile:TextBox id="year" Alignment="Left" Size="4" MaxLength="4" Runat="server"></mobile:TextBox> <mobile:RegularExpressionValidator id="forYear" runat="server" ControlToValidate="year" ErrorMessage="Enter a valid year" ValidationExpression="\d{4}">Enter a valid year</mobile:RegularExpressionValidator> <mobile:Label id="professionL" runat="server">Profession:</mobile:Label> <mobile:SelectionList id="profession" runat="server" Visible="True" OnInit="callProfessionFill"></mobile:SelectionList> <mobile:Label id="cargoL" runat="server">Cargo:</mobile:Label> <mobile:SelectionList id="cargo" runat="server" Visible="True" OnInit="callCargoFill"></mobile:SelectionList> <mobile:Label id="pinL" runat="server">PIN:</mobile:Label> <mobile:TextBox id="pinT" runat="server" Size="10"></mobile:TextBox> <mobile:RequiredFieldValidator id="forPin" runat="server" ControlToValidate="pinT" ErrorMessage="Enter your PIN">Enter your PIN</mobile:RequiredFieldValidator> <mobile:Label id="msisdn" runat="server">MSISDN</mobile:Label> <mobile:TextBox id="msisdnT" runat="server"></mobile:TextBox> <mobile:Label id="email" runat="server">Email</mobile:Label> <mobile:TextBox id="emailT" runat="server"></mobile:TextBox> <mobile:Label id="ip" runat="server">IP</mobile:Label> <mobile:TextBox id="ipT" runat="server"></mobile:TextBox> <BR> <mobile:Command id="register" OnClick="checkForm" runat="server">Register</mobile:Command> </mobile:form> </body>
You probably will get the answers to all ur questions on seeing the above code!
My .CS file Looks like this
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.Mobile; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.MobileControls; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using Sam.Services.Subscription.DemographicOption;
namespace SAMPRO { /// <summary> /// Summary description for MobileWebForm1. /// </summary> public class sam_registration : System.Web.UI.MobileControls.MobilePage {
protected System.Web.UI.MobileControls.SelectionList sex; protected System.Web.UI.MobileControls.TextBox month; protected System.Web.UI.MobileControls.TextBox date; protected System.Web.UI.MobileControls.TextBox year; protected System.Web.UI.MobileControls.Command register; protected System.Web.UI.MobileControls.Label error; protected System.Web.UI.MobileControls.Label heading; protected System.Web.UI.MobileControls.Label text; protected System.Web.UI.MobileControls.Label nameL; protected System.Web.UI.MobileControls.TextBox nameT; protected System.Web.UI.MobileControls.Label lnameL; protected System.Web.UI.MobileControls.TextBox lnameT; protected System.Web.UI.MobileControls.Label sexL; protected System.Web.UI.MobileControls.Label BD; protected System.Web.UI.MobileControls.Label professionL; protected System.Web.UI.MobileControls.Label cargoL; protected System.Web.UI.MobileControls.Label pinL; protected System.Web.UI.MobileControls.TextBox pinT; protected System.Web.UI.MobileControls.Label msisdn; protected System.Web.UI.MobileControls.TextBox msisdnT; protected System.Web.UI.MobileControls.Label email; protected System.Web.UI.MobileControls.TextBox emailT; protected System.Web.UI.MobileControls.Label ip; protected System.Web.UI.MobileControls.TextBox ipT; protected System.Web.UI.MobileControls.SelectionList profession; protected System.Web.UI.MobileControls.SelectionList cargo; protected System.Web.UI.MobileControls.RangeValidator forMonth; protected System.Web.UI.MobileControls.RangeValidator forDate; protected System.Web.UI.MobileControls.RequiredFieldValidator forUser; protected System.Web.UI.MobileControls.RequiredFieldValidator forLname; protected System.Web.UI.MobileControls.RequiredFieldValidator forPin; protected System.Web.UI.MobileControls.RegularExpressionValidator forYear; protected System.Web.UI.MobileControls.Form registration;
private void Page_Load(object sender, System.EventArgs e) {
}
#region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // 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
public void checkForm(object sender, EventArgs e) { if (Page.IsValid && year.Text != "") { try { System.DateTime dtn = DateTime.Now; string fd = month.Text +"/" +date.Text +"/" +year.Text +" 00:00:00 AM"; System.DateTime dt = System.DateTime.Parse(fd); Response.Write("is" +dt); if (dt > dtn) { error.Text= "please check the date u entered"; error.Visible = true;
} registration.Action = "sam_welcome.aspx"; } catch { error.Text = "The date entered should be a valid date"; error.Visible = true; } } else { error.Text = "Please enter the year"; error.Visible=true; }
}
// /// <summary> /// this function is called when the label text gets // initialised. Its basically to show up with a text message /// </summary> /// <param name="sender"></param> /// <param name="e"></param>
public void fillText(object sender, EventArgs e) { text.Text = "Welcome to carrier's service, please enter the following information to create you account and allow our system provide you with the benefits"; }
/// <summary> /// This function is called when the form is loaded, It basically /// checks for the flag value in the URL, while called. /// If flag = 1 then we know there was an error while we try to /// register the user(the CreateUser method returns a value 0) /// /// If flag = 2 then we know that the user failed to enter the /// all the required fields. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void check(object sender, EventArgs e) { string flag = Request.QueryString["flag"]; if (flag == "1") { error.Text= "There was an error while registering you!"; error.Visible = true; } else if (flag=="2") { error.Text= "Please enter the complete information"; error.Visible = true; } else if (flag=="3") { error.Text= "Please check the year you entered"; error.Visible = true; } } /// <summary> /// This function is called when the selection list(profession) /// is initialized. /// /// Library used: Sam.Services.Subscription.DemographicOption /// Class used: DemographicOptionClient() /// Method used: GetDemographicOptionClient() /// Parameters: /// 1)demoSettingId:Is always 1 when used for profession type:int. /// /// Control used: Selectionlist, Id = profession. /// Datasource property= The dataset(rows) returned by the method GetDemographicOptionClient() /// DataTextField property = The coloumn demographicOptionName. /// DataValueField property = The coloumn demographicOptionId. /// /// Purpose: This approach enables to add a new profession with /// out changing the code. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void callProfessionFill(object sender, EventArgs e) { int demoSettingId = 1; try { DemographicOptionClient d = new DemographicOptionClient(); DemographicOptionDataSet ds = d.GetDemographicOptionsBySettingId(demoSettingId);
profession.DataSource = ds.DemographicSettingsOptions.Rows; profession.DataTextField = "demographicOptionName"; profession.DataValueField = "demographicOptionId"; profession.DataBind(); } catch (Exception err) { error.Text = err.Message; error.Visible = true; return; }
}
/// <summary> /// This function is called when the selection list(cargo) /// is initialized. /// /// Library used: Sam.Services.Subscription.DemographicOption /// Class used: DemographicOptionClient() /// Method used: GetDemographicOptionClient() /// Parameters: /// 1)demoSettingId:Is always 2 when used for cargo, type: int. /// /// Control used: Selectionlist, Id = cargo. /// Datasource property= The dataset(rows) returned by the method GetDemographicOptionClient() /// DataTextField property = The coloumn demographicOptionName. /// DataValueField property = The coloumn demographicOptionId. /// /// Purpose: This approach enables to add a new cargo without /// changing the code. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void callCargoFill(object sender, EventArgs e) { int demoSettingId = 2; try { DemographicOptionClient d = new DemographicOptionClient(); DemographicOptionDataSet ds = d.GetDemographicOptionsBySettingId(demoSettingId); cargo.DataSource = ds.DemographicSettingsOptions.Rows; cargo.DataTextField = "demographicOptionName"; cargo.DataValueField = "demographicOptionId"; cargo.DataBind(); } catch (Exception err) { error.Text = err.Message ; error.Visible = true; return; } }
} }
SN
-----Original Message----- From: Anil John [mailto:Click here to reveal e-mail address] Sent: Monday, July 01, 2002 4:29 PM To: aspngmob Subject: [aspngmob] Re: Field Validators & <mobile:Command>
Suresh,
Please post the complete aspx page and the code behind so that I can replicate the problem (Copy and paste in VS.Net and run the code). The information that you've provided is incomplete.
Some questions as well:
Is there a particular reason that you are using response.write in your mobile page rather than setting the value equal to a label control?
What is the error control? Where are the values of month, year, date coming from?
Anil
---------- Original Message ---------------------------------- From: Suresh Nair <Click here to reveal e-mail address> Reply-To: "aspngmob" <Click here to reveal e-mail address> Date: Mon, 1 Jul 2002 13:03:40 -0400
My .cs file !:
if (Page.IsValid && year.Text != "") { try { System.DateTime dtn = DateTime.Now; string fd = month.Text +"/" +date.Text +"/" +year.Text +" 00:00:00 AM"; System.DateTime dt = System.DateTime.Parse(fd); Response.Write("is" +dt); if (dt > dtn) { error.Text= "please check the date u entered"; error.Visible = true;
} registration.Action = "sam_welcome.aspx"; } catch { error.Text = "The date entered should be a valid date"; error.Visible = true; } } else { error.Text = "Please enter the year"; error.Visible=true; }
Just the mobile:command info from the aspx file!
<mobile:Command id="register" OnClick ="checkForm" runat="server">Register</mobile:Command>
Thanks SN
-----Original Message----- From: Anil John [mailto:Click here to reveal e-mail address] Sent: Monday, July 01, 2002 1:05 PM To: aspngmob Subject: [aspngmob] Re: Field Validators & <mobile:Command>
Suresh,
Please post the code for your page...
In addition, how are you testing your pages? Using IE or with an emulator?
Anil
---------- Original Message ---------------------------------- From: Suresh Nair <Click here to reveal e-mail address> Reply-To: "aspngmob" <Click here to reveal e-mail address> Date: Mon, 1 Jul 2002 09:50:15 -0400
-- Moved from [aspngfreeforall] to [aspngmob] by Marcie Jones <Click here to reveal e-mail address> --
Hi guys!
I have some validators added to my mobile form, and under the button(<mobile:Command> Like a submit button it has to post my variables to the next page) click event, I check for the page.IsValid first and then set my Form action to the next page I would want to go.
The strange thing here is, the validations works perfectly, But then i need to make 2 clicks on the button to traverse to the next page. To be more precise, on the 1st click it checks and validates all the controls that i want to validate and on the 2nd click it takes me to the next page. Now i have no clue about this at all.
Let me know if you guys out there have any any any clue!
Thanks SN | [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
-- -- Anil John - http://LearnMobile.net -- #1 .net Mobile & Wireless Resource -- Connect with .net - Anytime. Anywhere. --
| [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
| [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
| [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
| [aspngmob] member Click here to reveal e-mail address = YOUR ID | http://www.asplists.com/asplists/aspngmob.asp = JOIN/QUIT | http://www.asplists.com/search = SEARCH Archives
|
|
| |
|
| |
| Suresh Nair |
Good morning Anil!
Thank you for your time on this!
The target device is IMode phones which goes with a browser that could interpret CHTML! I have developed 2 applications for the same device using ASP, Now since we have the Mobile Internet toolkit coming with the .Net framework i was trying my hands on that.
The databinding like you say can be done on the page load event, But i dont see any performance or any other issue while i am doing it this way, unless u would want to comment otherwise on it.
Not wireing the submit button to a validate function, I am sorry i didnot understand as to what you mean here, well if its the property CausesValidation =True, then i tried that and it still doesnt like that ;-). Please let me know if i got you right.
Please let me know what makes you think that this page is not natively created for a mobile device?
Regarding the validation of the page, i have only used the mobile:RangeValidator and mobile:RegularExpressionValidator which actually comes with the tool box, so i really donot understand, when you say best practices.
Because as you say i may want to go ahead and make this a cross-device mobile page!
I again thank you for the time and appreciate your this effort.
Thanks SN
-----Original Message----- From: Anil John [mailto:Click here to reveal e-mail address] Sent: Monday, July 01, 2002 7:05 PM To: aspngmob Subject: [aspngmob] Re: Field Validators & <mobile:Command>
After playing around with this, I have some comments and questions for you..
What is your target device? From the Html constructs that you have within this form, I am assuming that it is probably a pocket pc device... If so why aren't you using a regular asp.net form?
Why are you not databinding to a dropdown list(s) on page load (You seem to be using a OnInit fuctions to prefill instead)
The reason that you are having to click twice is because you have not wired up the Submit button to the validate function. Instead you are wiring it up to a custom Onclick event instead!
It really looks as though this was not natively created mobile web form but is instead an existing asp or asp.net page that you are trying to make into a mobile page..
I would suggest that you look at the best practices for databinding, validation and rewrite this page from scratch if the intent is to make this a cross-device mobile page.
Anil
-----Original Message----- From: Suresh Nair [mailto:Click here to reveal e-mail address] Sent: Monday, July 01, 2002 4:41 PM To: aspngmob Subject: [aspngmob] Re: Field Validators & <mobile:Command>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" %> <%@ Page language="c#" Codebehind="sam_registration.aspx.cs" Inherits="SAMPRO.sam_registration" AutoEventWireup="false" %> <meta content="Microsoft Visual Studio 7.0" name="GENERATOR"> <meta content="C#" name="CODE_LANGUAGE"> <meta content="http://schemas.microsoft.com/Mobile/Page" name="vs_targetSchema"> <body Xmlns:mobile="http://schemas.microsoft.com/Mobile/WebForm"> <mobile:form id="registration" OnLoad="check" BackColor="#E0E0E0" Method="Get" runat="server"> <mobile:Label id="heading" runat="server" ForeColor="#FF3333" Alignment="Center" Font-Bold="True">SAM Registration</mobile:Label> <BR> <mobile:Label id="error" runat="server" ForeColor="Red" Alignment="Center" Font-Bold="True" Visible="False"></mobile:Label> <BR> <mobile:Label id="text" runat="server" Alignment="Center" OnInit="fillText">text</mobile:Label> <BR> <mobile:Label id="nameL" runat="server" Alignment="Left">Name:</mobile:Label> <mobile:TextBox id="nameT" runat="server" Size="10"></mobile:TextBox> <mobile:RequiredFieldValidator id="forUser" runat="server" ControlToValidate="nameT" ErrorMessage="Enter Username">Enter Username</mobile:RequiredFieldValidator> <mobile:Label id="lnameL" runat="server" Alignment="Left">Last Name:</mobile:Label> <mobile:TextBox id="lnameT" runat="server" Size="10"></mobile:TextBox> <mobile:RequiredFieldValidator id="forLname" runat="server" ControlToValidate="lnameT" ErrorMessage="Enter Lastname">Enter Lastname</mobile:RequiredFieldValidator> <mobile:Label id="sexL" runat="server" Alignment="Left">Sex:</mobile:Label> <mobile:SelectionList id="sex" runat="server" Alignment="Left" SelectType="Radio"> <Item Value="1" Selected="True" Text="Male"></Item> <Item Value="2" Text="Female"></Item> </mobile:SelectionList> <mobile:Label id="BD" runat="server">Birth Date:</mobile:Label> <mobile:TextBox id="month" Alignment="Left" Size="2" MaxLength="2" Runat="server"></mobile:TextBox> <mobile:RangeValidator id="forMonth" runat="server" ControlToValidate="month" ErrorMessage="Invalid Month" MaximumValue="12" MinimumValue="1">Invalid Month</mobile:RangeValidator> <mobile:TextBox id="date" Alignment="Left" Size="2" MaxLength="2" Runat="server"></mobile:TextBox> <mobile:RangeValidator id="forDate" runat="server" ControlToValidate="date" ErrorMessage="Invalid Date" MaximumValue="31" MinimumValue="1">Invalid Date</mobile:RangeValidator> <mobile:TextBox id="year" Alignment="Left" Size="4" MaxLength="4" Runat="server"></mobile:TextBox> <mobile:RegularExpressionValidator id="forYear" runat="server" ControlToValidate="year" ErrorMessage="Enter a valid year" ValidationExpression="\d{4}">Enter a valid year</mobile:RegularExpressionValidator> <mobile:Label id="professionL" runat="server">Profession:</mobile:Label> <mobile:SelectionList id="profession" runat="server" Visible="True" OnInit="callProfessionFill"></mobile:SelectionList> <mobile:Label id="cargoL" runat="server">Cargo:</mobile:Label> <mobile:SelectionList id="cargo" runat="server" Visible="True" OnInit="callCargoFill"></mobile:SelectionList> <mobile:Label id="pinL" runat="server">PIN:</mobile:Label> <mobile:TextBox id="pinT" runat="server" Size="10"></mobile:TextBox> <mobile:RequiredFieldValidator id="forPin" runat="server" ControlToValidate="pinT" ErrorMessage="Enter your PIN">Enter your PIN</mobile:RequiredFieldValidator> <mobile:Label id="msisdn" runat="server">MSISDN</mobile:Label> <mobile:TextBox id="msisdnT" runat="server"></mobile:TextBox> <mobile:Label id="email" runat="server">Email</mobile:Label> <mobile:TextBox id="emailT" runat="server"></mobile:TextBox> <mobile:Label id="ip" runat="server">IP</mobile:Label> <mobile:TextBox id="ipT" runat="server"></mobile:TextBox> | | |