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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Eyadtrabulsi
    New Member
    • Mar 2007
    • 40

    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"
  • joerozario
    New Member
    • Mar 2007
    • 60

    #2
    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

    Comment

    • Eyadtrabulsi
      New Member
      • Mar 2007
      • 40

      #3
      But when I specify the attributes for the imagebutton I couldn't reach OnClick event

      I mean:
      ImageButton1.On Click
      is not available to invoke the function by it when user clicks the image, it's protected..

      Comment

      • computerenigma13
        New Member
        • Mar 2007
        • 36

        #4
        Originally posted by Eyadtrabulsi
        But when I specify the attributes for the imagebutton I couldn't reach OnClick event

        I mean:
        ImageButton1.On Click
        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

        Comment

        • Eyadtrabulsi
          New Member
          • Mar 2007
          • 40

          #5
          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_Cl ick";
          imageBtt[i].ImageUrl = image;

          ContentPlaceHol der3.Controls.A dd(imageBtt[i]);
          i++;
          }

          I receives this error:

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

          Compiler Error Message: CS0122: 'System.Web.UI. WebControls.Ima geButton.OnClic k(System.Web.UI .ImageClickEven tArgs)' is inaccessible due to its protection level

          I don't know if I commited silly fault, but I'm not professional yet..

          Comment

          • Eyadtrabulsi
            New Member
            • Mar 2007
            • 40

            #6
            I'm wondering how could it be useful to get an event with no functionality following it I could link by .OnClick's contents

            Comment

            • Eyadtrabulsi
              New Member
              • Mar 2007
              • 40

              #7
              !! Shifted to be answered...

              Comment

              • Eyadtrabulsi
                New Member
                • Mar 2007
                • 40

                #8
                Please help me guys, it's the last step..

                Comment

                • joerozario
                  New Member
                  • Mar 2007
                  • 60

                  #9
                  make this function public

                  "ImageButton_Cl ick";

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

                  u can still add more function for a control

                  controlname.Att ributes.Add("on click","javascr ipt:popUpCalend ar(this, "+ txtDate.ClientI D + ",'MM/dd/yyyy');");

                  Comment

                  • Eyadtrabulsi
                    New Member
                    • Mar 2007
                    • 40

                    #10
                    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#

                    Comment

                    • Eyadtrabulsi
                      New Member
                      • Mar 2007
                      • 40

                      #11
                      I don't want to encode my optional "OnClick", I mean that I want the standard ImageButton.OnC lick to execute specific function when clicking the button which I added automatically

                      Maybe there is missunderstandi ng about what exactly I want to do..

                      Comment

                      • Eyadtrabulsi
                        New Member
                        • Mar 2007
                        • 40

                        #12
                        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

                        Comment

                        • Eyadtrabulsi
                          New Member
                          • Mar 2007
                          • 40

                          #13
                          Please somone tells me if it's possible to use .OnClick event with Auto-generated ImageButton

                          Comment

                          • Eyadtrabulsi
                            New Member
                            • Mar 2007
                            • 40

                            #14
                            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..

                            Comment

                            • Eyadtrabulsi
                              New Member
                              • Mar 2007
                              • 40

                              #15
                              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

                              Comment

                              Working...