|
|
|
|
|
|
|
Author Rank :
|
|
|
Page Views :
|
2258
|
|
Downloads :
|
0
|
|
Rating :
|
Rate it
|
|
Level :
|
Beginner
|
|
Here is a simple Form which checks if the input text is a palindrome or not. This serves as a good introduction to the relatively new world of Programming for Mobile Web Forms using the Mobile Internet ToolKit. Our tools for this small experiment will be our familiar editor - Notepad or any other text editor. Alternatively we can also use the Microsoft Mobile Internet Designer in Microsoft Visual Studio.Net.
Step 1> Directives
Add the directives to the start of the Mobile Page-if you plan to program a lot for Mobile Web Forms, you can expect to see a lot of these lines (as a matter of fact - In every mobile page you create !)
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" Language="cs" %> <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
Step 2> User Input
Now we add some lines for getting the user input (We have to care what the user wants-right ?)
<mobile:Form runat="server" ID="Form1"> <mobile:Label runat="server" ID="Label1">PALINDROME CHECK</mobile:Label> <mobile:Label runat="server" ID="Label2">Enter the word:</mobile:Label> <mobile:TextBox runat="server" id="Word" /> <mobile:Command runat="server" OnClick="cmdSubmit_OnClick" Text="Check!" ID="Command1"/> </mobile:Form> <mobile:Form runat="server" id="Result"> <mobile:Label runat="server" id="lblMessage" /> </mobile:Form>
This simply adds labels, a text box and a button control to the Mobile page.
When the button is clicked, the function "cmdSubmit_OnClick" is invoked.
Step 3> Function
Let's check out the "juicy" details of cmdSubmit_OnClick-this function will be doing core of the work for us.
We extract the word entered by the user in the mobile page, reverse it and compare the two-if the two are equal-we have a palindrome on our hands !
The script evaluates the word and the results are displayed on the Results label on Form2-Note that Form2 is displayed by making it the ActiveForm
<script runat="server" language="c#"> protected void cmdSubmit_OnClick(Object sender, EventArgs e) { try { char[] reverse = Word.Text.ToCharArray(); Array.Reverse (reverse); String strreverse = new String(reverse); if (strreverse != Word.Text) lblMessage.Text = Word.Text + " is not a palindrome"; else lblMessage.Text = Word.Text + " is a palindrome"; } catch(Exception ex) { lblMessage.Text = "Error in operation. Please try again"; } ActiveForm = Result; } </script>
Step 4> How Does It Look ?
You can verify the mobile page on your cell phone or an emulator or your friendly neighborhood Internet Explorer.

Figure 1: Input mobile page

Figure 2 : Output mobile page

Figure 3: Now we know that "palindrome" is not a palindrome.
|
|
Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post
Here.
|
|
|
|
|
Login
to add your contents and source code to this article
|
|
|
|
|
|
|
|
|
|
|
|
Dipal Choksi
Dipal Choksi has over 10 years of industry experience in team-effort projects and also as an individual contributor. She has been working on the .Net platform since the beta releases of .Net 1.0.
|
|
|
|
|
|
|
|
|
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional
consulting company, our consultants are well-known experts in .NET and many of them
are MVPs, authors, and trainers. We specialize in Microsoft .NET development and
utilize Agile Development and Extreme Programming practices to provide fast pace
quick turnaround results. Our software development model is a mix of Agile Development,
traditional SDLC, and Waterfall models.
|
|
Click here to learn more about C# Consulting. |
|
|
|
|
|
|
|
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon.
Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees.
As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
|
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
|
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
|
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
|
|
|
|
|
|
|
|
|
|
|
|
|