.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Disable "enter" click on imagebutton

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :ASP.Net
When i press "enter" i dont want the first button that is on my page getting fired. This is a imagebutton. I did try with a javascript function that checks the event keycode but this always returns 13.<script language="javascript"> function noEnter() {  if (event.keyCode == 13) {  return false;    }  }  </script> When i add OnClientClick="return false;" then you can't press the button at all.<asp:ImageButton ID="backButton" runat="server" CausesValidation="false" ImageAlign="AbsBottom" ImageUrl="../../images/Global/back.gif" OnClientClick="GoBack2_Click" OnClick="GoBack_Click" OnClientClick="return false;"/> When i click with the mouse on the button the Goback function does not get called. So what i'm trying to get here that the imagebutton need to be clicked with a mouseclick and not with and enter keystroke. ty ;)      

View Complete Post

More Related Resource Links

how can I disable right click on the picture of website?

Hi Friends, Could you please recommend me a solution to disable right click on the pictures of website? thanks in advance , sepid  

Click imagebutton open window.open in class asp.net 2.0

Click imagebutton open window.open in class asp.net 2.0

Disable button on first click

Hey folks, I have this below piece of code which fires on second time but not first time for me. I am using it as a login button checking for Username n password validations. Please correct. I don't want to use javascript:btnLogin.Attributes.Add("onclick", "this.disabled=true;" + Page.ClientScript.GetPostBackEventReference(btnLogin, "").ToString())  

confirm JS is not working on imagebutton click


Dear Frens

I have a new issue, which i want to share.

When working with ASP.NET 1.1 Framework there is an imagebutton on click of that imagebutton client side validations are fired since it is an online application form

cline side validations are must i am using a javascript when user submitting the application form

for confirm messege .

but it is not working ... if i do the causevalidation="False" for the imagebutton it is working but the validation are bypassed.

How to achieve this please suggest

Thanks in Advance


>>How to open a page in seperate browser when Imagebutton click from parent page?



In parent page there is an imagebutton. What I want to when user click this image button, another page will open with width=200 and height=100 with no toolbar.

detect enter keypress and trigger button click (all browsers)


I have some textbox's that when the enter key is pressed on them, i should fire a buttons action (say the go button).

Seems that it no longer works accross current browsers and  i was wondering if anyone has some nice javascript or something to detect if enter is pressed and fire a button click action (accross all current browsers - ie8, ff, safari, chrome etc)

ImageButton Click Event Not Working


I know this question has been asked before. But for some reason I can't find the exact answer I need for my problem. My problem is as follows:

I am creating a web page (The one posted is just an easy example) that creates multiple ImageButtons on one page via a loop.I have tried many other ways (for example, create instance in form_load and pass to the WriteHtml() method) but I can't figure out a way to complete this. In this example I have 10 buttons that need to be able to be clicked.

Thanks in advance,


The code is as follows:

    public partial class _Default : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)

        private void WriteHtml()
            StringWriter sw = new StringWriter();

            using (HtmlTextWriter writer = new HtmlTextWriter(sw))
                for (int i = 0; i < 10; i++)
                    ImageButton imgBtn = new ImageButton();
                    imgBtn.ID = "imgBtn_" + i;
                    imgBtn.ImageUrl = "images.jpg";
                    imgBtn.Attributes.Add("runAt", "server");
                    imgBtn.Click += new ImageClickEventHandler(imgBtn_Click);

how to disable right click with message window along with IP address ?


I want to disable right click on my website and would like to display a popup window on right click, along with the person's IP address who right clicked on my website, how to accoplish that ?

Till now i have added this script on my master page which disable right on I.E but doesn't popup any message window and it works in mozilla and shows popup. why message is not poping up in I.E ?

<script type="text/javascript">
            var message = "Right Click Have Been Disabled!";
            function clickIE() { if (document.all) { alert(message); return false; } }
            function clickNS(e) {
(document.layers || (document.getElementById && !document.all)) {
                    if (e.which == 2 || e.which == 3) { alert(message); return false; }

How to disable Windows 7 right click close of winforms.?


How to disable Windows 7 right click close of winforms.?

When right click of the icon on the taskbar,shows close option to close the form.

How to disable it?


how to disable one button after fisrt click in a day


i want the submit button be disable after  user click one time , i meant i want 1 user has rights to submit onetime only in a day . thank

ImageButton click -> new window open

Hi all,
I have an ImageButton with PostBackUrl="~/AnotherForm.aspx".
Whether exists or not any way to open the AnotherForm.aspx page in different window?
Tnx in advance!

Disable Mouse Right click in datagrid


Hi Friends,

       Can any one Suggest,how to disable mouse right click in WPF Datagrid.


Thanks in Advance,


disable button in page load click event using javascript



i have button its  enable false in aspx page, if i click the page load  click event  then button should enable

looking forward the reply.

C# Click on Enter Game in Game! How i can do this?



How i can click on button: Enter Game, in game:


My code


public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

[DllImport("user32.dll" , CharSet = CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, uint wMsg, int wParam, IntPtr lParam);

[DllImport("user32.dll" , EntryPoint = "FindWindowExW" , SetLastError = true ,
CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindowEx(IntPtr Ph, IntPtr Ch,
IntPtr Ph1,
String lpWindowName);

stop postback after imagebutton click on page validation error



i have some textbox that i validate with a customvalidator control (only, and must be, server side function) and i have an imagebutton control for submit.

I must stop the postback if there are some errors in the validation function.

I set the validation property argumets.isvalid = false in the customvalidator function but doesn't work, the postback continue.

i have tried to set the imagebutton property postbackurl = "" in the validation function but doesn't work.

Where is the error?

Javascript Disable on Enter key not working?


Hi, I have a weird little problem here with a form login page.  I'm building on top of some other code, so it's a bit hack and slash, but what I want at this point is just to disable the Enter key.  I use javascript and it does work, the enter key stops working. 

UNLESS the mouse cursor is in the password textbox, then hitting enter triggers a form submit. 

Any idea why this is happening? Or how I can redirect the enter click?  Right now everything I seem to try just results in a form submit.



GridView Javascript Click Row and Ajax

This article shows 2 common tasks with the ASP.NET GridView: Binding a List (generic) of objects as DataSource and on clicking a row, getting the values of the selected row by a javascript function. In the example a List with User-objects is displayed. On clicking a row containing the data of a User-object, the Id of the object is used to get the address of the user by an Ajax-call and display it in a details-field.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend