简体   繁体   中英

Using User Control in Master Page - Need Focus

This is the scenario:

I have a Master Page, In the Master Page I have a user control In the User Control there is a code that looks like this

<div>
<a id="p1" runat="server">
    <asp:Image ID="Img" runat="server" ImageAlign="AbsMiddle" Style="position:relative;
        bottom: 0px;" /></a> -<a id="p2" runat="server">
            <asp:Label ID="lblRate" runat="server"></asp:Label>
            Rates</a>
 </div>

Now, when the user clicks on "Rates" it should focus on an item that is another User Control back in the Master Page.

How can I do this?, this is existing code and can not modify the current structure but what is currently happening is that when "Rates" is clicked it postsback with a parameter goto=rates but doesnt do anything.. I need to make so that when it is clicked it focuses on another UserControl in the Master Page. (but this "Rates" link is User Control too)

I tried in my Master Page the following

if(!Page.Postback)
{
   if(Request.Params["goto"] == "rates"){ 
    uControl.Focus(); 
    }
}

No luck, please help:(

So to recap:

MasterPage has UserControl -> UserControl has a link that postsback with parameter goto=rates -> back in the MasterPage I need to focus the screen on another UserControl.

I tried to be as clear as I could

Thank you

Looks like you have a not opperator where you should. You should change if(.Page.Postback) to if(Page.Postback) .

not all controls supports focus like this. for your user control, you may need build javascript to setup focus.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM