Setting Server Control Properties Based on Target Browser

You can set a different value for a property for IE than for Firefox - and for anything else. I didn't try all properties, but I did try many that would matter, such as Text and OnClientClick etc, and they do work. Take a look at the following markup:

<asp:Label runat="server" ID="labelText" 
ie:Text="This is IE text"
mozilla:Text="This is Firefox text"
Text="This is general text"
/>

<br />

<asp:Button runat="server" ID="buttonText"
ie:Text="IE Button"
ie:OnClientClick="javascript:alert('Hello IE!');"
mozilla:Text="FF Button"
mozilla:OnClientClick="javascript:alert('Hello Firefox!');"
Text="General Button"
OnClientClick="javascript:alert('Hello everyone else!');"
/>


Notice the "ie:" and "mozilla:" prefixes on the Text and OnClientClick properties.

Read more...

 

1 Comment

Comments have been disabled for this content.