开发者

Error when two server controls have same ID's

I am not the programmer, I dont have access to the Code Behind.

I just style the pages and whatnot.

PROBLEM: I am trying to hide/show elements of a page based on the language selected.

Some of these elements are server controls and a couple of them have specific id's and graphics associated.

I need to change the graphics to the language selected.

I have tried this:

   <%if Request.QueryString("lang")="es" then%>
<div><asp:imagebutton id='go' ImageUrl='go-spanish.png'></asp:imagebutton></div>
<% Else %>
<div><asp:imagebutton id='go' ImageUr开发者_JS百科l='go-english.png'></asp:imagebutton></div>
<% End If %>

No dice.

I also tried using Response.Write to write the imagebuttons dynamically, which it does, but they arent visible in the browser.

I also tried changing the image path in the control dynamically and apparently it isnt allowed.

Could someone please give me an idea of how to work around this?


Have only one imagebutton and then in the page_load event set it's ImageUrl property based on the selected language. This would probably cause issues if the page_load event was already declared in the code behind page though.


Use a variable to set your image string based on language and then just generate one control using the variable for your image.


Almost certainly not possible

It heavily depends on the inner processing of this particular page, but you probably won't be able to do this. If this particular original image button (as I understand you, you've simply added another language image button) has event handlers in the codebehind, you won't be able to just add another button and make it just work. This original particular button (if it actually worked) definitely has click even handler attached to. And it doesn't check any additional info, so the same handler can't be reused for an additional button. Even if you'd change it's ID to something else.

Javascript can't help you here either. Code will have to change in the codebehind.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜