ASP and PostBack

G

Guest

Hi,

I'm new with ASP .NET, so i'm asking lots of questions latly...

I've a web Page, with a button which i've created dynamicly and attached an
Click event to it.
as i understood here, i need to recreate the button again in the postback
event.

the problem is that i need this button, in a specific location (after i've
created few more labels and button).

so what's haapens is that in the postback i'm creating the button for the
event, and then i'm creating all my dynamic labels and i need to create this
button again (or move it to different location), if i do so, I'm getting an
error saying that control with the same ID is already exists, so before i'm
recrating it, i tried to find it in the Conrols list and couldn't. (and
wanted to remove it).

what's the right way to do it?

Thanks a lot,
Gidi.
 
N

Nicholas Paldino [.NET/C# MVP]

Gidi,

I don't see why you need to create another button in the postback event.
The exception you are getting obviously is showing that the button is
already there with that control id. Have you looked at the page in the
debugger to determine if the control is indeed there in the postback?
 
C

Cor Ligthert[MVP]

Gidi,

If you create a button dynamicly, then you have to create it again
dynamicly.

If you have first created it fysical in the HTML code, then it is there, and
you can not replace it in another way, than using that object and give it
another place in HTML code. That is hard (almost impossible) to do if it is
located in a fixed way. Should then be in HTML dynamicly, but that has again
its troubles, because you are not controling the settings of the user.

That as far as I understand your problem.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top