Connor Mackay
Connor Mackay

Reputation: 77

How to Concatenate an Asp.net control name with a string

Basically I have a few asp.net objects. I get the ID of object 1 and assign it to a string. I then want to add a control to a placeholder than end in that ID. Not too sure how to go about doing this.

        string id = Regex.Match(btnCreateHazard.ID, @"\d+$").Value;
        phHazard(SOMEHOW GET THE ID HERE).Controls.Add(txtHazardDesc);

Thanks a lot.

Upvotes: 2

Views: 412

Answers (1)

Ashu
Ashu

Reputation: 477

What i understood id you want to add a string to a control that u can do like this..

 string id = Regex.Match(btnCreateHazard.ID, @"\d+$").Value;
 placeholderId.Controls.Add(id);

OR

can refer below example. https://msdn.microsoft.com/en-us/library/kyt0fzt1.aspx

Upvotes: 1

Related Questions