.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

ImageButton onClick

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
 I created an image button called "pic1" with the OnClick feature. When clicked it runs "btnClicked".   In the sub "btnClick", how would I get information? One example is to get the button tooltip.  I tried this: request.form.item("pic1.tooltip"). That did not work.

View Complete Post

More Related Resource Links

Extended ImageButton control's OnClick not firing


I extended an ImageButton control and its image is changing as expected, but its OnClick is not firing.  

namespace ECP.ServerControls
    [ToolboxData("<{0}:ExtendedImageButton runat=server></{0}:ExtendedImageButton>")]
    public class ExtendedImageButton: ImageButton
        protected override void OnPreRender(EventArgs e)
                    if (HttpContext.Current.Request.Cookies["happy_cookie"] != null )
                        this.ImageUrl = "http://domain/apple.gif";
                        this.Click += new ImageClickEventHandler(AppleAlert);
                        this.ImageUrl = "http://domain/mango.gif";
                        this.Click += new ImageClickEventHandler(MangoAlert);


        protected AppleAlert(object sender, ImageClickEventArgs e)

        protected void MangoAlert(object sender, ImageClickEventArgs e)

I need help with imagebutton links


I have imagebuttons as links and i added the attributes for mousedown, up and out. That works fine.  I cant seem to figure out how that the imagebutton itself, when pushed, stays down and returns to normal when the user clicks another link....

what I was thinking of doing is calling a method on the onclick event of the button and letting it check whether there is another button pushed down then to send the found link button to its orginal state.

I figured doing the call and checking of the buttons would be long winded with the method, so there must be an easier way to do this ?




ModalPopup/UpdatePanel from codebehind, inconsistent behavior onClick


First post bear with me please:

I have a simple form with a list of linkbuttons, each fires the same onclick event which sets an indicator image.  I have a dummy button with style="display:none" which I have set as the TargetControlID of the modal.

onClick event from the imagebutton, the modal is shown via modal.Show().  The cancel button inside the modalpopup fires an event which turns off the indicator image and hides the modal via modal.Hide(). 

The events fire perfectly, it's very simple!  Although after doing some testing I noticed the modalpopup is not presented after the 6-10th cycle of clicking the open event, then clicking cancel.  The grey background appears but it is behind the main panel and the modal is either presented behind this or is just simply not displaying. 

I spent hours researching various methods, implemented the CancelControlID to see if it was somehow tied to my call of modal.Hide() that fails.

This occurs with an updatepanel only.  The behaviour is much cleaner this way, so I would hope to be able to implement this.  I have basically eliminated everything but these two events!  Please help

onclick and onclientclick


Hei I have the following line in asp.net

<asp:LinkButton runat="server" ID="createuser" OnClientClick="javascript:$('#dialogform').dialog('open');" onclick="AddCaseInfo_Click">Create Case</asp:LinkButton>

Onclientclik works fine, but not onclick :(  Any help please?

Object expected error


<input type="button' onclick="timeoutCheck()" value="Click Me!" />

it tells me Microsoft JScript runtime error: Object expected


timeoutCheck() is my script function that i declared above the input tag

can anyone tell me why i am getting this error

hello i need help , any ideas are welcome i have been working on this for two weeks now and cannot seem to be able to advance

Suppress postback on ImageButton


I have the following JavaScript defined for the OnClientClick event of an ImageButton:

var _oHasChanged = $get(_chkHasChanged); if (_oHasChanged && _oHasChanged.checked) { alert('De gewijzigde gegevens moeten worden opgeslagen alvorens deze actie kan worden uitgevoerd.'); return false; }

As you can see, I have "return false;" after the alert, because I don't want a postback in that situation.

This is working just fine in Firefox, but Internet Explorer seems to ignore the "return false;" bit and posts back to the server anyway.

What am I missing here?

Image or ImageButton rounded corners


Hiiiii Coders,

I just want to make corners of my asp.net image or imagebutton rounded. How can i do so?  

onclick() between client side and server side

Hello, I want to enhance a composite control's client side, my approach is to recreate all method on JavaScript, so here I have some troubles : 1) Can I call onclick event on client side otherwise on server side ? 2)  the statement table.onclick=SelectRow(event) fires a bug ! Hello,I want to enhance a composite control's client side, my approach is to recreate all method on JavaScript, so here I have some troubles :1) Can I call onclick event on client side otherwise on server side ?2)  the statement table.onclick=SelectRow(event) fires a bug !

imagebutton, sub signature, by ref

Hi Below is my codeThe first 3 lines are run in the DataList1_ItemDataBound event and they call the sub below, of which there is the opening line.My question is if I change the signature from System.Web.UI.WebControls.Image toSystem.Web.UI.WebControls.ImageButton this still works and vice versa so it'll work in the found control is either a imagebutton or image.1. Can anyone explain why it does work fine either way?2. The ByVal ImgProfile As System.Web.UI.WebControls.Image, should this be ByRef, aren't controls passed by reference rather than value?Or I am getting this mixed up. The reason why I say this is I can modify the image control that's passed in and if it was passed by value then I shouldn't be able to modify the control, or should I?Dim Image1 As ImageImage1 = CType(e.Item.FindControl("ImageButton1"), Image)DisplayImage(UserID, Image1)Protected Sub DisplayImage(ByVal pUserID As String, ByVal pImgProfile As System.Web.UI.WebControls.Image)thanks.

Save an ImageButton to the viewstate?

Hi!I have created a custom control that extends the class ImageButton, the thing is that I now also want to save this control to a viewstate...is there anyway to do this?Thanks in advance!

ImageButton does not fire

Hi.I have the following image button:<asp:ImageButton ID="submit" EnableViewState="true"                                   ImageUrl="/images/btn_submit.png" AlternateText="Submit" CssClass="f-right"                                 runat="server" onclick="submit_Click"></asp:ImageButton>The event is fired in Firefox but not in IE*. anyone any ideas?ThanksJason.

Treeview node to add onclick event to download files

 Hi, I would like to know how to add onclick evend to a TreeNode so that the file can be downloaded.   How can I implement below sample code to a TreeNode? <a href="#" onclick="popup('/directory1/Somefile.doc'); return false;" target="download"> Somefile </a> <script language="javascript"> function popup(url) { popWin = window.parent.open(url, 'popWindow', 'height=900, width=900, toolbar=no, menubar=yes, scrollbars=yes, titlebar=no, resizable=yes,location=0, directories=no, status=no'); } </script> I have TreeNodePopulate event to populate nodes like this: protected void DocRepository_TreeNodePopulate(object sender, TreeNodeEventArgs e) { .... String[] files = Directory.GetFiles(fullPath); foreach(String file in files) { TreeNode newNode  = new TreeNode(Path.GetFileName(file), Path.GetFileName(file)); node.ChildNodes.Add(newNode); } }   Thank you in advance.              

onclick on control with eval dosn't work

Hi, I have an aspx control with works perfectly:<asp:HyperLink ID="lnkSeekJob" runat="server" Text="Søgt job" NavigateUrl='<%# "SeekJob.aspx?id=" + Eval("companyPId")%>' Target="SeekJob" name="SeekJob" onClick="wopen('SeekJob.aspx?id=3', 'popup', 600, 480); return false;" /> The problem is that the id isn't always 3 - so I have to get the rows id - I try this with eval:<asp:HyperLink ID="lnkSeekJob" runat="server" Text="Søgt job" NavigateUrl='<%# "SeekJob.aspx?id=" + Eval("companyPId")%>' Target="SeekJob" name="SeekJob" onClick='<%# "wopen('SeekJob.aspx?id=" + Eval("companyPId") + ", 'popup', 600, 480); return false;"%>' /> But I then get the error: The server tag isn't weel formed. I think (I'm pretty sure) it's because of the "/' . They aren't set correctly. Can anyone help me - so I set these correctly? Kind regards, simsen :-)

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

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


Hi all,Here's some simple code<a href='<%= string.Format("../Print/Print1.aspx?withParameter={0}", Para )%>'>HyperLinkText</a>and it works well. so i guess i can write anything like this, so i wrote a test:<input type="button" value="Btn1" onclick='<%= string.Format("window.open('','_blank')") %>'/> <input type="button" value="Btn2" onclick="window.open('','_blank')"/>However, Btn1 does not work.. for some reason i have to NOT to use server control, so i wite it in inline-code style,why the first hyperlink work well, but Btn1 fails?could anyone tell me?thank you~

Disable "enter" click on imagebutton

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 ;)      

Problem with Imagebutton/general questions

Hello,I am new to .NET development, to HTML and javascript, actually to the whole "web" scenario, however I am a game programmer (AS, Java, C#...) but I am having some trouble with some aspects of web programming (actually one, the "statelessness" of it =P) and the syntax is also new to me so there are some things that I have an idea of how to make, but cant actually make it without hours of research on the web.My first question here is one that I guess should be very simple. I am developing a picture album, and there are 2 images that serve as buttons to go to the next page. However, some albuns will not have more pictures then one page. What Im doing is detecting wheter or not my List.count is higher or lower then the required number to have multiple pages. If it is, the ImageButton of the "nextpage" btn will be "image1" and in case its not, "image2". However, on the page code I tryed using the same method I am using for pictures.Regular Picture:<img src='<%= VerificarThumb(8)%>' alt="Teste"/>ImageButton:<asp:ImageButton ID="prxpg" runat="server" ImageUrl="<%= VerQtd(false)%>" Height="93px" onclick="PrxPg" Width="31px" PostBackUrl="~/Default.aspx" />This does not work. Is there some other way to call a C# method for
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