locked
Problem with Form Authentication & DeviceSpecific control in Mobile Web Application RRS feed

  • Question

  • User-295291898 posted

    Hello,

            I am developing an Mobile Web application which need to be use Form Authentication. Below is some of the problem i am facing, i have also given the code snippet of my code.

    1. I have developed one login page and implement form authentication & it works fine until i place one Device specific control in to it. It's Only when filter is "IsHTML32", it works fine when i made WML request in Openwave simulator.

    2. I have placed validation controls in to it and when i check Page.IsValid on code behind file it always return false. When i check the validated control(textbox) of this validator it always return "". It's Only when filter is "IsHTML32", it works fine when i made WML request in Openwave simulator.

    3. When i print User.Identity.Name it always print blank. It's Only when filter is "IsHTML32", it works fine when i made WML request in Openwave simulator.

    Login.aspx Page 

    <mobile:Panel ID="pnlContent" Runat="server">
                <mobile:DeviceSpecific ID="dsContent" Runat="server">
                    <Choice Filter="isHTML32" Xmlns="http://schemas.microsoft.com/mobile/html32template">
                        <ContentTemplate>
                            <table border="1px" width="100%">
                                <tr>
                                    <td valign="middle" align="center">
                                        <table border="1px">
                                            <tr>
                                                <td colspan="2">
                                                    <mobile:Label ID="lblHTMLLogin" Runat="server" BreakAfter="false">Login</mobile:Label></td>
                                            </tr>
                                            <tr>
                                                <td valign="Top">
                                                    <mobile:Label ID="lblHTMLUserName" Runat="server" BreakAfter="false">UserName: </mobile:Label>
                                                </td>
                                                <td>
                                                    <mobile:TextBox ID="txtHTMLUserName" Runat="server" BreakAfter="false">
                                                    </mobile:TextBox>
                                                    <mobile:RequiredFieldValidator ID="rfvHTMLUserName" Runat="server" ControlToValidate="txtHTMLUserName"
                                                        ErrorMessage="User Name Required" BreakAfter="false">
                                                    </mobile:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td valign="Top">
                                                    <mobile:Label ID="lblHTMLPassword" Runat="server" BreakAfter="false">Password: </mobile:Label>
                                                </td>
                                                <td>
                                                    <mobile:TextBox ID="txtHTMLPassword" Runat="server" Password="True" BreakAfter="false">
                                                    </mobile:TextBox>
                                                    <mobile:RequiredFieldValidator ID="rfvHTMLPassword" Runat="server" ControlToValidate="txtHTMLPassword"
                                                        ErrorMessage="Password Required" BreakAfter="false">
                                                    </mobile:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                    <mobile:Command ID="cmdHTMLLogin" Runat="server" OnClick="cmdLogin_Click" BreakAfter="False">Login</mobile:Command>
                                                    <mobile:Command ID="cmdHTMLReset" Runat="server" OnClick="cmdReset_Click" CausesValidation="False"
                                                        BreakAfter="false">Reset</mobile:Command>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </ContentTemplate>
                    </Choice>
                </mobile:DeviceSpecific>
                <mobile:Label ID="lblLogin" Runat="server">Login</mobile:Label>
                <mobile:Label ID="lblUserName" Runat="server">UserName: </mobile:Label>
                <mobile:TextBox ID="txtUserName" Runat="server">
                </mobile:TextBox>
                <mobile:RequiredFieldValidator ID="rfvUserName" Runat="server" ControlToValidate="txtUserName"
                    ErrorMessage="User Name Required">
                </mobile:RequiredFieldValidator>
                <mobile:Label ID="lblPassword" Runat="server">Password: </mobile:Label>
                <mobile:TextBox ID="txtPassword" Runat="server" Password="True">
                </mobile:TextBox>
                <mobile:RequiredFieldValidator ID="rfvPassword" Runat="server" ControlToValidate="txtPassword"
                    ErrorMessage="Password Required">
                </mobile:RequiredFieldValidator>
                <mobile:Command ID="cmdLogin" Runat="server" OnClick="cmdLogin_Click" BreakAfter="False"
                    StyleReference="">Login</mobile:Command>
                <mobile:Command ID="cmdReset" Runat="server" OnClick="cmdReset_Click" CausesValidation="False">Reset</mobile:Command>
            </mobile:Panel>
     
    Login.aspx.cs Page 

    protected void cmdLogin_Click(object sender, EventArgs e)
    {

            if (Page.IsValid)
            {
                    MobileFormsAuthentication.RedirectFromLoginPage(Convert.ToString(txtUserName.Text).Trim(), true);
                    FormsAuthentication.RedirectFromLoginPage(Convert.ToString(txtUserName.Text).Trim(), true);
            }

    }

     

    Please help me out...waiting for your earliest reply.

    Thanks,

     

    Monday, August 18, 2008 3:48 AM

Answers

  • User-1113931457 posted

     Hi anand,

    sorry i don't get all your questions. in number 2 your saying Page.IsValid is always returning false.  

    that is true, as your using four validating controls in your page. When your requesting your page from web browser, like IE then

    only first part of your code will be visible according to your DeviceSpecific control. So other two will remain empty.

    and page will not validate unless all four validator controls are valid. You can check it by commenting the following portion,

                <%--<mobile:Label ID="lblLogin" Runat="server">Login</mobile:Label>
                <mobile:Label ID="lblUserName" Runat="server">UserName: </mobile:Label>
                <mobile:TextBox ID="txtUserName" Runat="server">
                </mobile:TextBox>
                <mobile:RequiredFieldValidator ID="rfvUserName" Runat="server" ControlToValidate="txtUserName"
                    ErrorMessage="User Name Required">
                </mobile:RequiredFieldValidator>
                <mobile:Label ID="lblPassword" Runat="server">Password: </mobile:Label>
                <mobile:TextBox ID="txtPassword" Runat="server" Password="True">
                </mobile:TextBox>
                <mobile:RequiredFieldValidator ID="rfvPassword" Runat="server" ControlToValidate="txtPassword"
                    ErrorMessage="Password Required">
                </mobile:RequiredFieldValidator>
                <mobile:Command ID="cmdLogin" Runat="server" OnClick="cmdLogin_Click" BreakAfter="False"
                    StyleReference="">Login</mobile:Command>
                <mobile:Command ID="cmdReset" Runat="server" OnClick="cmdReset_Click" CausesValidation="False">Reset</mobile:Command>--%>

     

    Why don't you build two separate pages, One for Mobile and another for Web browser.

    and make decision on the page_load event.

    if (Request.Browser.IsMobileDevice)
    Response.Redirect("MobileDefault.aspx");
    This will be easy to mange. 
     Thanks. 
      
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 20, 2008 9:09 AM