RE: postback in asp.net 2.0

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks !..but your assumption is wrong. I am working on a situation where the
user actually clicks a button.

"Kannan.V [MCSD.net]" wrote:

> I assume that you are looking for something like pressing the enter key
> should fire a button click even other than the default button.
> if my assumption is correct then the answer is in a simple client-side
> javascript function called whenever a button is pressed, that, if the button
> pressed is the Enter key, cancels the default submit and simulates a click on
> the wanted button. Here's the function, that you can copy and paste as-is
> into your ASPX pages, or that you can paste into a separate .js file,
> referenced by any ASPX page that needs it:
>
> < language="javascript">
> function KeyDownHandler(btn)
> {
> // process only the Enter key
> if (event.keyCode == 13)
> {
> // cancel the default submit
> event.returnValue=false;
> event.cancel = true;
> // submit the form by programmatically clicking the specified button
> btn.click();
> }
> }
> < /script>
>
> Now, in the input controls declaration you just have to call this function
> when a button is pressed, by handling the onKeyPressed client-side event, and
> pass a reference to the default button:
>
>
> < runat="server" id="FN" onkeydown= "KeyDownHandler(DefButton)">
>
> --
> Kannan.V
> Home : http://www.kannanv.com
> Blog : http://kannanv.blogspot.com
> Web : http://www.DotnetLounge.net
>
> "Any one who has never made a mistake has never tried anything new" - Einstein
>
>
> "getdotnet" wrote:
>
> > hello,
> > I am using a form which has multiple buttons(asp server controls) say B1, B2
> > and B3. The postabck gets fired on B1 click whereas I want it to happen on B3
> > click. I know that by default the first button on a page is set as the
> > 'submit' button and that is the reason for this behaviour.
> > Now teh question is, how can i prevent postback firing on B1 click and force
> > it to fire on B3 click. i heard asp.net has a simple way to handle this and
> > there is no need to write a _dopostback javascript function.
> >
> > Can somebody help me on this?
> >
> > Thanks
> >
.



Relevant Pages

  • Re: Namespaces - broad question
    ... Reference the Class Library in your Page, ... > aspx pages that I know I want utilize a specific function within, ... > have the same codebehind page), how can I reference this function. ... >> A .Net assembly is a compiled DLL. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Namespaces - broad question
    ... that way, to make it simpler to reference them during development, instead ... use with one aspx page. ... > When VS.NEt compiles your web project, it places all the classes in one ... How can you write a page that inherits ...
    (microsoft.public.dotnet.framework.aspnet)
  • Multiple Codebehind Pages? Possible/Practical?
    ... multiple methods and where to store these methods (e.g. one codefile or ... OnSelectedIndexChanged) are referenced in the derived .aspx pages as ... Once I execute the category dropdownlist (using only one of the ... I have a .dll with all the code, and then just reference the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Trans from ASP to ASP.NET 2.0 via 1.0
    ... As for the reference to a code file, look at the @Page tag at the top of the ... "show code" button when the aspx page is selected. ... books for 2.0. ... I have text-searched the .aspx file for the following strings (case ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Auto-Comilation of .CS classes???
    ... The thing is, though, you can sort-of do it in ASPX page using the "assembly ... Where this is a problem, for me, is that I have several user controls. ... do it without precompiling. ... Because you reference it in the codebehind cs file ...
    (microsoft.public.dotnet.framework.aspnet)