Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2008

Tip: Looking for answers? Try searching our database.

Dynamic ID in Webcontrol

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andre - 30 Jun 2008 02:45 GMT
Hi.
There is a way, that I can create a dynamic ID in a WebControl.
This doesn´t work, but, looks like what I want:

<asp:Button ID="btnAdd<%="1"%>" runat="server" Text="Add Resposta"
OnClick="btnAdd_Click" />

I´ve tried to set up the id at the finish of the aspx, but, when I get
in the codebehind, the id is the original.
Doesn´t change.

What I looking for is:
I have many usercontrols in a page, I need a way to get a value that
represents the unique usercontrol clicked.
For this, I need the dynamic id in the button to diferentiate a user
control from anothers.
Changing the id in postback like this:
if (!Page.IsPostBack)
{
    btnAdd.ID = "btnAdd" + _hdPerguntaID;
}

doesn´t work because I´m using ajax extensions and the page always is
in PostBack.

Thanks in advance

Andre
Riki - 30 Jun 2008 10:31 GMT
> Hi.
> There is a way, that I can create a dynamic ID in a WebControl.
[quoted text clipped - 24 lines]
>
> Andre

Changing the ID dynamically seems inappropriate to me, because the ID
is essential for the postback mechanism.

But the actual ID of the different buttons in the page will be composed
of the user control ID and the button ID, something like
MyUserControl1_btnAdd.
I suggest extracting the number from that ID, which will give you a unique
number for each user control.

Signature

Riki


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.