CodeVerge.Net Beta
Login Idy
Register Password
  Forgot?
Explore    Item Entry    Members   
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 10/13/2005 11:14:08 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 3 Views: 8 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
4 Items, 1 Pages 1 |< << Go >> >|
SteveSu
Asp.Net User
Problem with defaultbutton for panel10/13/2005 11:14:08 AM

0/0

Hello!
I have problem setting the button which is the default for a textbox in a specific scenario. If I write code like this:

<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
<asp:Panel ID="Panel1" runat="server" Height="50px" DefaultButton="Button1" Width="125px">
   <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
   <asp:Button ID="Button1" runat="server" Text="Button" />
</asp:Panel>

Also I have a Panel containing one textbox and one button. Having focus in the textbox i want to always use button1 when hitting enter on the keyboard.
I have set Defaultbutton on the panel to that button and it works good. My problem is if I for example add?s a linkbutton outside the panel. 
If I now do the following scenario something, which is strange to me, happens.
1.)  Click the Linkbutton which makes a postback.
2.)  Hit back-button in Internet Explorer.
3.) Focus on Textbox again. And press enter.
Now the Linkbutton event is postbacked instead of the button which I always want to be hitted when the focus is in the panel. Why is that?

JoeBerg
Asp.Net User
Re: Problem with defaultbutton for panel10/13/2005 5:11:02 PM

0/0

Hi Steve, this is a known issue; the EventTarget and EventArgument fields aren't cleared when using the Back Button of the browser. This means that they are going to be posted back to the server again. The work-around for this issue is to clear those fields before the form is submitted; something like this:

<head runat="server">
    <script>
        function clearValues()
       {
            theForm.__EVENTTARGET.value ='';
            return true;
       }
    </script>
</head>

<body>

<form id="form1" runat="server" onsubmit="return clearValues();">


Hope this helps,
Joe
SteveSu
Asp.Net User
Sv: Re: Problem with defaultbutton for panel10/14/2005 9:10:13 AM

0/0

Thanks a lot JoeBerg!
Works great!
plauborg
Asp.Net User
Re: Problem with defaultbutton for panel10/20/2006 9:06:22 AM

0/0

Hi Joe,

I have the same problem, but I use a MasterPage, so I don't have the form-tags to put the clearValues() function in... Can the same thing somehow be done in the C# codebehind file??

Thanks
Peter

4 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

DefaultButton in UpdatePanel - asp.net_ajax.asp ... <asp:Panel ID="Panel1" runat="server" DefaultButton="Button1" ... I wonder if anyone is having the same problem with the 1.0 version of ajax ? ...
Using Panel.DefaultButton property with LinkButton control in ASP.NET ... ... simplest way to solve the problem is to define click() method for ... Setting link button as Default button for FIREFOX as well as IE: use this fallowing code ...
Default Focus, Buttons and Validation Errors with ASP.NET 2.0 ... For this situation I was able to resolve the problem with one line ... example with Deault buttons functions fine, but when my panel and default button there ...
UpdatePanel Problem... - ASP.NET Forums after it I putted the panel in UpdatePanel [ for Ajax ] My problem is: ... <asp:Panel ID="PanelMSG" runat="server" DefaultButton="btnMSG" Width="398px" ...
Enter Key in ASP.NET - Complete Research New defaultbutton attribute can be used with <form> or <asp:panel> control. ... cursor is and what button is chosen as a default button for form or a panel. ...
[SOLVED] DefaultButton [SOLVED] DefaultButton ... More strange but explain the problem. ... as the default button, if not, you may want to try referencing the panel as such: ...
Defaultbutton | Dmytro Shteflyuk's Home Using Panel.DefaultButton property with LinkButton control in ASP.NET. Aug 25 ... In this article I will show why this problem take place and how to solve it. ...
Panel's DefaultButton whims: not every IButtonControl is the same ... So, how could we solve this problem and make DefaultProperty works with... say... FireFox? ... register the default button scrtipt with reflection ...


 
All Times Are GMT