Tuesday, January 16, 2007

Hi

 

This is a tricky, I think if I didn't study yesterday I will never know about this.

You can make a button pass the page to server without validation by using the Button ( Command ) property CausessValidation

 

This is an example

 

<%@ Page Language="C#"

    Inherits="System.Web.UI.MobileControls.MobilePage" %>

<%@ Register TagPrefix="mobile"

    Namespace="System.Web.UI.MobileControls"

    Assembly="System.Web.Mobile" %>

 

<script runat="server">

 

    protected void Command1_Click(object sender, EventArgs e)

    {

        if (Page.IsValid)

            ActiveForm = Form3;

    }

 

    protected void Command2_Click(object sender, EventArgs e)

    {

        ActiveForm = Form3;

    }

</script>

 

<html xmlns="http://www.w3.org/1999/xhtml" >

<body>

    <mobile:form id="form1" runat="server">

        <mobile:Label ID="Label2" Runat="server">Write a value</mobile:Label>

        <mobile:TextBox ID="TextBox1" Runat="server">

        </mobile:TextBox>

        <mobile:RequiredFieldValidator ID="RequiredFieldValidator1"

            Runat="server" ControlToValidate="TextBox1"

            ErrorMessage="Text is required ">

        </mobile:RequiredFieldValidator>

        <mobile:Command ID="Command1"

            Runat="server"

            OnClick="Command1_Click"

            Format="Link">Validate </mobile:Command>

        <mobile:Command ID="Command2"

            Runat="server"

            CausesValidation="False"

            OnClick="Command2_Click"

            Format="Link"

            SoftkeyLabel="No Validation !!!">No Validation</mobile:Command>

 

    </mobile:form>

    <mobile:Form ID="Form3" Runat="server">

        <mobile:Label ID="Label3"

            Runat="server"

            ForeColor="Green"

            StyleReference="title">You Passed</mobile:Label>

    </mobile:Form>

</body>

</html>

 

Have fun

Bye

 

0 comments:

Post a Comment