Problems with Dinamic controls

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Problems with Dinamic controls

    i want to create dinamicaly an image Button, but i'm not able to associate a
    relative server command on click, any idea ?

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    Dim oImageButton As New System.Web.UI.WebControls.ImageButton()
    oImageButton.CssClass = "tab"
    oImageButton.ID = "test"
    oImageButton.CommandName = "test"
    oImageButton.CausesValidation = True
    oImageButton.EnableViewState = True
    PlaceHold.Controls.Add(oImage)
    end


    Alessandro Guest

  2. Similar Questions and Discussions

    1. dinamic address in dreamweaver
      Hi there!! I have a web site with database (APS - MS Access - Dreamweaver), and I would like to to storage images in a folder on my server and...
    2. Dinamic Text and URL
      Hello!: Does anyone knows if there is a tutorial on how to display text in a flash animation from a .txt file (i know this is possible). What I...
    3. Problems with dinamic text and masks...
      Somebody can help me, please? I need use a dinamic text (in flash mx) with any mask over that text.... The problem is that dinamic text with a...
    4. Dinamic controls creation
      Hi, please see following thread at ASP.NEt Forums: http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=250529 -- Teemu Keiski...
    5. problems with key controls
      I am experiencing a number of problems in my 3D environment. I have a model that is controlled by the arrow keys - left arrow key - moves character...
  3. #2

    Default Re: Problems with Dinamic controls

    If I understand you, you are missing the click event.

    This should help you:
    oImageButton.Click += new System.EventHandler(this.oImageButton_Click);

    where oImageButton_Click is a function like this:

    private void oImageButton_Click(object sender, System.EventArgs e)
    {
    Do something...
    }

    Hope this helps

    Bjoern Wolfgardt

    "Alessandro" <gemini_two@hotmail.com> schrieb im Newsbeitrag
    news:#xiUpf2SDHA.2248@TK2MSFTNGP11.phx.gbl...
    > i want to create dinamicaly an image Button, but i'm not able to associate
    a
    > relative server command on click, any idea ?
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > Dim oImageButton As New System.Web.UI.WebControls.ImageButton()
    > oImageButton.CssClass = "tab"
    > oImageButton.ID = "test"
    > oImageButton.CommandName = "test"
    > oImageButton.CausesValidation = True
    > oImageButton.EnableViewState = True
    > PlaceHold.Controls.Add(oImage)
    > end
    >
    >

    Bjoern Wolfgardt Guest

  4. #3

    Default Re: Problems with Dinamic controls

    You should also create you button in the Page_Init event. If not, then the
    event will not be detected.

    The reason for this is that the viewstate for the control is loaded before
    the Page_Load so if you create the control in the page_load then what
    happens:
    1. the viewstate is loaded, the button is not found so no viewstate is
    loaded into it
    2. Button is loaded in the page_load
    2. because the viewstate was not loaded, the event will not be triggered.

    In the case that you load the button in the page_init this happens:
    1. Button is loaded in the page_init
    2. viewstate is loaded for the control is loaded
    3. the event on the button click is triggered.

    I hope this cleared things up...

    /Cristian


    "Alessandro" <gemini_two@hotmail.com> wrote in message
    news:%23xiUpf2SDHA.2248@TK2MSFTNGP11.phx.gbl...
    > i want to create dinamicaly an image Button, but i'm not able to associate
    a
    > relative server command on click, any idea ?
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > Dim oImageButton As New System.Web.UI.WebControls.ImageButton()
    > oImageButton.CssClass = "tab"
    > oImageButton.ID = "test"
    > oImageButton.CommandName = "test"
    > oImageButton.CausesValidation = True
    > oImageButton.EnableViewState = True
    > PlaceHold.Controls.Add(oImage)
    > end
    >
    >

    Cristian Suazo Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139