473,323 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Why many of ImageButton webcontrol's events are protected!!?

Why many of ImageButton webcontrol are protected!!? like .OnClick and how could we reach them when we add ImageButton automatically??

I need to click the on the automatically added icon, so it sends the event to it's function, but I couldn't make it because you cannot reach .OnClick event, it's protected!!
and so is the "runat"
Mar 20 '07 #1
17 2907
there are two types of control
1. html control
2 .asp.net control

if u use html control then u have to write function in java scrip for onclick()

if it is a asp control u can get the event by duble clicking on the immage

thank u
Mar 20 '07 #2
But when I specify the attributes for the imagebutton I couldn't reach OnClick event

I mean:
ImageButton1.OnClick
is not available to invoke the function by it when user clicks the image, it's protected..
Mar 20 '07 #3
But when I specify the attributes for the imagebutton I couldn't reach OnClick event

I mean:
ImageButton1.OnClick
is not available to invoke the function by it when user clicks the image, it's protected..
What control are you using asp or HTML cause joerozario had a good train if thought with what he said then go on that
Mar 20 '07 #4
I didn't reach this point...

I clarified my code as follows

ImageButton[] imageBtt = new ImageButton[images.Length];
foreach (string image in images)
{

imageBtt[i] = new ImageButton();
imageBtt[i].ID = "imageBtt" + i;
imageBtt[i].Visible = true;

imageBtt[i].OnClick = "ImageButton_Click";
imageBtt[i].ImageUrl = image;

ContentPlaceHolder3.Controls.Add(imageBtt[i]);
i++;
}

I receives this error:

Line 80: imageBtt[i].OnClick = "ImageButton_Click";

Compiler Error Message: CS0122: 'System.Web.UI.WebControls.ImageButton.OnClick(Sys tem.Web.UI.ImageClickEventArgs)' is inaccessible due to its protection level

I don't know if I commited silly fault, but I'm not professional yet..
Mar 21 '07 #5
I'm wondering how could it be useful to get an event with no functionality following it I could link by .OnClick's contents
Mar 21 '07 #6
!! Shifted to be answered...
Mar 22 '07 #7
Please help me guys, it's the last step..
Mar 22 '07 #8
make this function public

"ImageButton_Click";

add event arguments (sender ...,eventArguments e) for the function if u r calling from java script

u can still add more function for a control

controlname.Attributes.Add("onclick","javascript:p opUpCalendar(this, "+ txtDate.ClientID + ",'MM/dd/yyyy');");
Mar 22 '07 #9
I didn't get the point till now..

Why OnClick is protected, and how simply can I reach it instead of creating new one

Please someone helps me, I badly need your help to do this, I provided my code which is clear, if there is any information is required please let me know

P.S. I don't know about javascript, I work only with C#
Mar 24 '07 #10
I don't want to encode my optional "OnClick", I mean that I want the standard ImageButton.OnClick to execute specific function when clicking the button which I added automatically

Maybe there is missunderstanding about what exactly I want to do..
Mar 24 '07 #11
I tried both of the ways but it didn't work, I use ImageButton "not htmlImageButton" that means it's webcontrol

as for the first suggestion, I cannot double click on it because the ImageButton is not already exist, I generate it when loading the webpage, that what make me confused...

Why could I control OnClick event when ImageButton is already existed?? but cannot control it when I generate ImageButton at once, so there is no need to use ImageButton anymore, it would be the same as Image webcontrol !!!!

And why should I create new OnClick event by javascript, since it should be already available as feature of ImageButton
Mar 25 '07 #12
Please somone tells me if it's possible to use .OnClick event with Auto-generated ImageButton
Mar 26 '07 #13
Plz..... someone helps, I've been searching, reading and asking for more than a week, it's the last obstacle, if there is no solution please let me know..
Mar 26 '07 #14
what's happening with this community?? Am I talking myself !!? I need only to know why it's protected, don't need any solution, but should know a reason, because it doesn't make sense like this with .NET
Mar 27 '07 #15
raise up to be answered..
Mar 28 '07 #16
Now I got the solution myself, I submit it because might be useful for all after this long while trying to make that simple job..

We could use .Click instead of .OnClick as follows:

imageBtt[i].Click += new System.Web.UI.ImageClickEventHandler(ImageButton_C lick);


Thanks for all who tried to help me in this..
Mar 29 '07 #17
Thank you so much for posting your solution. I was struggling with this same problem for half a day before i found this thread. Support in the Microsoft community is utterly pathetic compared to the open source community.
Apr 16 '08 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Mark | last post by:
I have been working for quite some time on this issue which in theory should be quite simple. The problem is that the Cancel and Save events are not fired when their respective buttons are...
2
by: Mike Dinnis | last post by:
I know it's probably my code but I don't seem to be able to get OnClick events to tie up. The OnLoad and other standard events will fire but not a button onclick. Here's a sample of what i'm trying...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
2
by: Juan Romero | last post by:
Hey guys, I am working on a web custom control that basically draws a table (ASP Table) with a few child controls in the cells. I have a command button inside one of these cells. The problem I...
2
by: GGW | last post by:
Hi, I am building a Ecommerce site using usercontrols. I built a search control that uses the Ontextchaged event. The control was place manually on the page- not dynamiclly. All was working fine...
3
by: vcornjamb | last post by:
Hello, I am developing a web form that contains some buttons and a data grid which has as its last column link buttons that will delete the data associated with that row. Everything works fine,...
3
by: michael_vanommeren | last post by:
I have two web applications that I am working with and I am trying to do a Response.Redirect from one to the other. They are setup as separate web applications on the same IIS server. If I go...
2
by: Bruce | last post by:
I have a button on a form that creates multiple ImageButtons; I want each ImageButton's click event to then redirect to another URL. From doing some research, I understand this has to do with...
7
by: =?Utf-8?B?RWFnbGVSZWRASGlnaEZseWluZ0JpcmRzLmNvbQ== | last post by:
I am having trouble getting client-side events to fire on ImageButtons. Instead I am seeing postbacks. The client-side handlers end with "return false;" but they are never called. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.