|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Repeat web controls in ASPX pageI would like to create list of handled buttons with variable label within a code. Something like that: .... <body> <% foreach (Information information in Informations) { %> <!-- here will be a logic depending on the information - for example some conditions and different peices of code... that's a reason, why I cannot use repeater --> <asp:button runat="server" name="button1" Text="<%=information.Name%>"/> <% } %> </body> .... It of course doesn't work. But how to make this simple example working? Thank you! osup oSup wrote:
Show quoteHide quote > Hi, The solution here is probably to produce the HTML for the buttons> > I would like to create list of handled buttons with variable label > within a code. Something like that: > > ... > <body> > <% > foreach (Information information in Informations) { > %> > <!-- here will be a logic depending on the information - for example > some conditions and different peices of code... that's a reason, why I > cannot use repeater --> > > <asp:button runat="server" name="button1" > Text="<%=information.Name%>"/> > <% > } > %> > </body> > ... > > It of course doesn't work. But how to make this simple example > working? yourself, instead of using Button web controls. Instead of <asp:button ...> write: <input type="submit" value="<%=information.Name%>"> This is easy to understand if you know that the<%= %> syntax is executed when the page is rendered, and at that time, you are not allowed to add web controls anymore. -- Riki Thanks for your answer. But I have to use web controls (not exactly
asp:button, but some other third party components). And on the other side - if I will use repeater (i don't like it, because I have no control of presented information, and compose presented information in code-behind page is in contrast with common use of the class as "controller" - that's just my humble opinion), how can I operate with generated buttons in client javascript functions? (because buttons have some wierd id's)... Show quoteHide quote "Riki" <riki@nospam.com> wrote in message news:<uxK3AsxQFHA.2348@tk2msftngp13.phx.gbl>... > oSup wrote: > > Hi, > > > > I would like to create list of handled buttons with variable label > > within a code. Something like that: > > > > ... > > <body> > > <% > > foreach (Information information in Informations) { > > %> > > <!-- here will be a logic depending on the information - for example > > some conditions and different peices of code... that's a reason, why I > > cannot use repeater --> > > > > <asp:button runat="server" name="button1" > > Text="<%=information.Name%>"/> > > <% > > } > > %> > > </body> > > ... > > > > It of course doesn't work. But how to make this simple example > > working? > > The solution here is probably to produce the HTML for the buttons > yourself, instead of using Button web controls. > Instead of > <asp:button ...> > write: > <input type="submit" value="<%=information.Name%>"> > > This is easy to understand if you know that the > <%= %> syntax is executed when the page is rendered, > and at that time, you are not allowed to add web controls anymore. oSup wrote:
> Thanks for your answer. But I have to use web controls (not exactly This last question I can answer.> asp:button, but some other third party components). And on the other > side - if I will use repeater (i don't like it, because I have no > control of presented information, and compose presented information in > code-behind page is in contrast with common use of the class as > "controller" - that's just my humble opinion), how can I operate with > generated buttons in client javascript functions? (because buttons > have some wierd id's)... Use Button1.ClientID like this: document.getElementById("<%=Button1.ClientID %>") -- Riki I just posted on another thread that does something similar (HTH):
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/5e4ba4cfe5902a4b/a5717a97bd32c450?q=Brock+Viewstate+and+dynamic+controls&rnum=1#a5717a97bd32c450 -Brock DevelopMentor http://staff.develop.com/ballen Show quoteHide quote > Hi, > > I would like to create list of handled buttons with variable label > within a code. Something like that: > > ... > <body> > <% > foreach (Information information in Informations) { > %> > <!-- here will be a logic depending on the information - for example > some conditions and different peices of code... that's a reason, why I > cannot use repeater --> > > <asp:button runat="server" name="button1" > Text="<%=information.Name%>"/> > <% > } > %> > </body> > ... > It of course doesn't work. But how to make this simple example > working? > > Thank you! > > osup >
Uncheck Checkboxes
How to validate one of two Required TextBox Defining server-side Click event for Label web contol ? TemplateControl?? how to display records in datagrid Dynamic loadcontrol of ascx with dll not in bin path GridView Rows collection refresh within an event Textboxes with images Windows Explorer style custom control for web AddHandler / Remove Handler? |
|||||||||||||||||||||||