• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 176
  • Last Modified:

Web Button

Hello,

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

Thanks
Praveen
0
praveenuni
Asked:
praveenuni
1 Solution
 
CeiledCommented:
Sure there is...you'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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now