Click here to Skip to main content
15,912,021 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,
please see the following code.

XML
<body>
    <form id="form1" runat="server">
    <asp:Panel ID="Panel1" runat="server" Width="100" Height="300" BorderColor="Black"
        BorderWidth="1">
        <asp:Button ID="Button1" runat="server" Text="Back" />
    </asp:Panel>
    <br>
    <asp:Panel ID="Panel2" runat="server" Width="100" Height="300" BorderColor="Black"
        BorderWidth="1">
        <asp:Button ID="Button2" runat="server" Text="submit" />
    </asp:Panel>
    </form>
</body>
</html>




While clicking inside the second panel, the focus is coming to the 'Back Button' in IE. Please look into it.
Posted
Comments
Ankur\m/ 28-Feb-11 6:09am    
That's expected behaviour. What do you want?

use
UseSubmitBehavior="false"
in back button.

write like this
<form id="form1"  runat="server">  
  <asp:Panel ID="Panel1" runat="server" Width="100" Height="300" BorderColor="Black" BorderWidth="1">
    <asp:Button ID="Button1" runat="server" Text="Back" UseSubmitBehavior="false"/>
  </asp:Panel>
  <br />
  <asp:Panel ID="Panel2" runat="server" Width="100" Height="300" BorderColor="Black" BorderWidth="1">
    <asp:Button ID="Button2" runat="server" Text="submit" UseSubmitBehavior="false" />
  </asp:Panel>
  <br />
 </form>



Edit: new line tag and panel tag wasn't closed and causing formatting issue.
 
Share this answer
 
v3
Comments
Ankur\m/ 28-Feb-11 6:09am    
How would that solve the focus issue?
pankajupadhyay29 28-Feb-11 6:11am    
have u check this this will solve your problem

<form id="form1" runat="server">
<asp:Panel ID="Panel1" runat="server" Width="100" Height="300" BorderColor="Black"
BorderWidth="1">
<asp:Button ID="Button1" runat="server" Text="Back" UseSubmitBehavior="false"/>
</asp:Panel>
<br>
<asp:Panel ID="Panel2" runat="server" Width="100" Height="300" BorderColor="Black"
BorderWidth="1">
<asp:Button ID="Button2" runat="server" Text="submit" UseSubmitBehavior="false" />
</asp:Panel>
</form>

write like this
Ankur\m/ 28-Feb-11 6:17am    
Choose 'Improve Answer' to update your answer. OP doesn't get notified if you add a comment to yur answer.

More importantly, your answer is incorrect. UseSubmitBehavior="false" doesn't solve the focus issue mentioned in the question. Moreover it still postbacks the page.
pankajupadhyay29 28-Feb-11 6:29am    
thanks Ankur
and it is working i check for the same. the initial code provided focus the back button wherever you click in both the panel but now it is not show check both the code with IE.
Ankur\m/ 28-Feb-11 6:33am    
I am sorry I didn't get your point. But what I see in your code isn't the solution to the question. You have just added UseSubmitBehavior="false" in both the buttons. How does this have anything to do with focus on a control?


I guess you have completely misunderstood the Focus's behavior. Its in no way related to clicking inside the container of your control. For that, you will have to write a custom-event and in the code-behind you will have to finally include the line as

Button2.Focus();


This is what for which Focus is destined.

If you still have any concerns,can you please confirm if clicking on the panel and getting focus on the button was your requirement or were you just playing to have a feel of the Focus's behavior?

HTH

Regards
Rajeev



Please vote and mark answer as accepted if this helps you


 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900