Web Button

Posted on 2005-04-21
Last Modified: 2010-04-16

I'm creating a list of buttons in web custom control. When I'm creating them I'm giving the name of each button as this.UniqueId. But this is aslways giving me the "WebCustomControl1" as the UniqueId.  So for each button the UniqueId is "WebCustomControl". Is there anyway I can declare the UniqueID to be the 'Integer x', which will increment in a loop starting from 1. So Button1 will get UniqueID as 1,...

How can I do this?
Please help

Question by:praveenuni
    1 Comment
    LVL 7

    Accepted Solution

    Sure there're creating the buttons and setting their ID in code, right? Just do something like this...

    int currentID = 1;
    Button b1 = new Button();
    b1.UniqueID = this.UniqueID + currentID++;
    Button b2 = new Button();
    b2.UniqueID = this.UniqueID + currentID++;

    In other words, just keep track of a number, append it to the end of each UniqueID that you set (if you're using a for loop, then you can simply use your iteration variable), and incremet it after each one.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now