SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    CA
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Submitting login control from server side image map

    I have a login page with the login control laid out like so:

    (See line 32)

    Code:
    1    <asp:Login ID="loginControl" 
    2                TitleText=""
    3                DisplayRememberMe="false" 
    4                runat="server" 
    5                OnAuthenticate="loginControl_Authenticate"
    6                DestinationPageUrl="~/index.aspx"
    7                MembershipProvider="CMSProvider">
    8                <LayoutTemplate>
    9                
    10               <table width="514" border="0" align="left" cellpadding="0" cellspacing="0">
    11                 <tr>
    12                   <td width="221" height="39" align="left" valign="top"><img src="images/user.jpg" width="221" height="39" align="top"><br>
    13   </td>
    14                   <td width="15" height="39" align="left" valign="top" background="images/user_sp_middle.jpg"><img src="images/spacer.gif" width="15" height="10"><br /></td>
    15                   <td width="230" align="left" valign="middle" background="images/user_sp_middle.jpg">
    16                       <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox></td>
    17                   <td width="48" height="39" align="right" valign="top"><img src="images/user_sp_right.jpg" width="48" height="39"></td>
    18                 </tr>
    19                 <tr>
    20                   <td height="5" colspan="4" align="left" valign="top"><img src="images/user_sp_bot.jpg" width="514" height="22"></td>
    21                   </tr>
    22                 <tr>
    23                   <td width="221" height="10" align="left" valign="top"><img src="images/pass.jpg" width="221" height="39" border="0"></td>
    24                   <td align="left" valign="middle" background="images/pass_box.jpg"><img src="images/spacer.gif" width="15" height="10"></td>
    25                   <td align="left" valign="middle" background="images/pass_box.jpg">
    26                       <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox></td>
    27                   <td width="48" height="10" align="right" valign="top"><img src="images/pass_right_sp.jpg" width="48" height="39"></td>
    28                 </tr>
    29                 <tr>
    30                   <td height="19" colspan="4" align="left" valign="top" background="images/bg.gif" style="background-repeat:repeat"><img src="images/bot_sp_left.jpg" width="221" height="133">
    31   
    32   <asp:ImageMap HotSpotMode="PostBack" ImageUrl="images/bot_sp_right.jpg" ID="imLogin" runat="server"><asp:RectangleHotSpot Left="108" Top="21" Right="253" Bottom="58"/></asp:ImageMap></td></tr>
    33   		
    34   <tr><td height="10" background="images/bg.gif" style="background-repeat:repeat" colspan="4"></td></tr>
    35               </table>
    36   
    37   </LayoutTemplate>
    38   </asp:Login>
    In my code behind I have the Authenticate method:

    Code:
    1            protected void loginControl_Authenticate(object sender, AuthenticateEventArgs e)
    2            {
    3                DoLogin();
    4            }

    How would I submit the login for via image map click?

    Thanks!

  2. #2
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    call loginControl_Authenticate from your image map's click handler.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    CA
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wwb_99 View Post
    call loginControl_Authenticate from your image map's click handler.
    I tried that like this:

    <asp:ImageMap HotSpotMode="PostBack" ImageUrl="images/bot_sp_right.jpg" ID="imLogin" runat="server" OnClick="loginControl_Authenticate"><asp:RectangleHotSpot Left="108" Top="21" Right="253" Bottom="58"/></asp:ImageMap>

    I get the error:

    No overload for 'loginControl_Authenticate' matches delegate System.Web.UI.WebControls.ImageMapEventHandler'

    Could you give me a code example?

    Thanks for your help!

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    First you need to wire the imagemap to an appropriate handler:
    Code:
    <asp:ImageMap HotSpotMode="PostBack" ImageUrl="images/bot_sp_right.jpg" ID="imLogin" runat="server" OnClick="LoginMapClick"><asp:RectangleHotSpot Left="108" Top="21" Right="253" Bottom="58"/></asp:ImageMap>
    Then you need to patch the ImageMap's click event to the ImageMap's handler.

    Code:
    protected void ImageMapClick(object sender, ImageMapEventArgs e)
    //note signature might not be correct, check the type of the event args delegate
    {
       LoginControlEventArgs login=new LoginControlEventArgs();
       //set necessary properties
       loginControl_Authenticate(sender, login);
    }
    All that said, I think you can use an ImageButton on the login control and avoid the manual wiring if you are just looking to create the pretty button effect.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    CA
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sweet thanks wwb!

    Here's what I did:

    Code Behind:

    Code:
            protected void LoginMapClick(object sender, ImageMapEventArgs e)
            {
                AuthenticateEventArgs login = new AuthenticateEventArgs();
                loginControl_Authenticate(sender, login);
            }
    
            protected void loginControl_Authenticate(object sender, AuthenticateEventArgs e)
            {
                DoLogin();
            }
    aspx page:

    HTML Code:
    <asp:ImageMap HotSpotMode="PostBack" ImageUrl="images/bot_sp_right.jpg" ID="Login" runat="server" OnClick="LoginMapClick"><asp:RectangleHotSpot Left="108" Top="21" Right="253" Bottom="58"/></asp:ImageMap>
    Thanks a bunch for your help.

    Regards, WH


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •