Scorpio
Scorpio

Reputation: 1171

Dynamic Id on asp:Literal Cntrl

I want to add Id's to some ctrls as below, depending on the id's I want to change the server-side values for these controls. But i am getting compile time error -not a valid identifier. I know that this can be done in code behind but just wanted to know if it is possible to do it on apsx page.

Thanks for the concern

 <asp:Literal ID="ltrlTotalAmount_<%= trPlanYear.toString()%>" runat="server"></asp:Literal>

Upvotes: 1

Views: 265

Answers (1)

Brian Mains
Brian Mains

Reputation: 50728

You cannot assign an ID like that; the ID must be statically defined. You could use a client-side element instead. Even client-side input elements can be read by using the Request.Form collection on postback. Though you have to re-render them manually on every page postback.

Upvotes: 1

Related Questions