Hello all,
im writing an ASP.NET application and i wonder if is there a way that can i obtain the ASP.NET markup code(e.g. <asp:button etc etc) of a control that it is created 'on the fly'.


Please answer me as soon as possible, :)
Alex

Recommended Answers

All 7 Replies

i dont understand your question.

In short -- no. For standard <asp: you don't have to worry about tag prefixes either that you might with third party controls. Why are you trying to get at designer generated code in your application anyway? It isn't valid markup .. unless you are trying to write a code generator for making asp.net pages?

do u mean .....you want to create the control on the fly...?

In short -- no. For standard <asp: you don't have to worry about tag prefixes either that you might with third party controls. Why are you trying to get at designer generated code in your application anyway? It isn't valid markup .. unless you are trying to write a code generator for making asp.net pages?

That's exactly what i want to do. do you have any idea how can i do this?

Or can you provide me with other solutions that can help me in this situation? :S

Can you just build a list of known controls and use that? When you drop a control on the designer it calls RegisterTagPrefix() which handles getting the prefix name if it is already in use etc etc.

I would recommend dropping the controls on a form and getting the string values and going from there. You also have to update the .designer.cs file with the control names and classes. This isn't a straightforward thing to do but it can be done

what do you mean the string values of the control?? :S

Drop a control on to a web form and copy the code from the designer. Get the list of all designer generated code you need from hand. It shouldn't take more than 30 minutes to get them all. I think it may take hours to reflect out the information you need.. if its even possible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.