Mobile Page View Unit

This addition to the site retrieves the unit and shows the content of that page.

Description

Hi Friends,

Life is a devastating now a days as suddenly I started working on ColdFusion. And truly speaking life is damn moving as Market goes. And now I think I am aiming for that disloyal title which is very respectable in our area. You name it I know it. Anyway finally lets back to business. In the previous article we are up with storing Page and here is the retrieving unit the user will input the name of the page that he is looking for and we will show the content of that page.

First menu Page doesn't load any of these two units (MobilePagecreate and MobilePageView). There is one more menu page in between the main menu and the units. This menu (in between the main menu and the units) contains the links for "create" and "view" pages.

So here check out the unit for Retrieving Page

Source Code:

// Source Code Starts
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" Language="C#" Debug="true" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<%@ Import
Namespace="System" %>
<%@ Import
Namespace="System.Data"%>
<%@ Import
Namespace="System.Data.SqlClient" %>
<script runat="server" language="C#">
public string strAccessConn ="server=localhost;uid=sa;pwd=;database=practice";
public string str;
public void Page_View(Object sender, EventArgs e)
{
if(Page.IsValid)
{
SqlConnection myConn =
new SqlConnection(strAccessConn);
SqlCommand myCommand =
new SqlCommand("Select Page_Data from Page_Unit
where Page_Name like '"+pagename.Text+"'",myConn);
myConn.Open();
SqlDataReader myReader;
myReader = myCommand.ExecuteReader();
while(myReader.Read())
{
str= myReader["Page_Data"].ToString();
}
if(str == "")
{
str= "Hi No such Page Exists";
}
else
{
PageContent.Text= str ;
}
ActiveForm =Form2;
}
}
</script>
<
mobile:Form id = "Form1" runat="server">
<
mobile:Label runat="server" ID="Label1">Page Name</mobile:Label>
<
mobile:TextBox runat="server" id="pagename"/>
<
mobile:Command runat="server" OnClick="Page_View" Text="Go!"
ID="Command1"/>
</
mobile:Form>
<
mobile:Form runat="server" id="Form2">
<
mobile:Label id ="PageContent" runat="server"> </mobile:Label>
<
mobile:Link runat="server" NavigateURL="MobilePageEntry.aspx" ID="Link1">
Create New Page
</mobile:Link>
</
mobile:Form>
// Source Code End

This is Pretty simple and straightforward. So I hope it will be no Problem.

Rest in Next

bye

Shivani~~~~