tags:

views:

34

answers:

3

I have two different user controls both of which has a textbox with the ID: txtEmail. When I render both controls in MVC, I'm running into conflicting IDs. Does anyone have any suggestions to resolve this issue?

A: 

I would place a small snip of code in the controller that will assign a dynamic name based on which control its coming from.

Gnostus
+1  A: 

Yeah what I generally do is preface the id with the model name.

So my model might be MyModel so my id would be MyModel.txtEmail.

Unsure why you have txtEmail though in MVC. Generally you would have a textbox like so;

Html.TextBox("email") where email is the name of the field in your model.

griegs
A: 

What griegs said except that if you have strongly typed your view to use a model with Email in you can use <%: Html.TextBoxFor(model => model.Email) %>. It will prefix the ID for you with the model name and everything will generally rock. You will need MVC2 though

BritishDeveloper