Cross-browser compat. question

E

Eric Caron

Hi everybody,

I was doing some cross-browser tests today and I found out that if you
specify the width and height for a button type control, asp.net doesn't
output the style information when viewing the page with the latest version
of firefox. I copy-pasted the page source to an html file and opened it
with firefox and the styles were applied to the button with no problem. My
question is then this: Is there a way to control what ASP.NET outputs to
the browser or alter in some way its browser detection? It's a good thing
to suppress style information and functionality that browsers don't support,
but it's another when the browser in fact supports it. I suppose that for
microsoft, it basically boils down to "our browser" and "the others", but I
thought I would ask anyway.

Thanks for any help or insight!

Eric.
 
K

Ken Dopierala Jr.

Hi Eric,

Right now there isn't a totally easy way to have it span ASP.Net. However
you can do this manually without a lot of trouble. Basically you can
subclass a control (i.e. Button) and override the Render event so that you
output HTML that will be cross browser compatible. Then for each button you
place in all your applications you have them inherit from the Button that
you created.

Inside the Render event you can test for the browser type but an easier way
is to create an Enum of all the browsers you support. Then in the
contructor of your button set an internal property for the type of browser
detected. If it is one you support or need to do something for use that
enum to determine what to output. If it isn't a browser you have specific
support for you can call the base object Render event or create a real
scaled down plain option that should work with every browser.

Good luck! Ken.
 
B

bruce barker

force asp.net to behave, try:

private void Page_Load(object sender, System.EventArgs e)
{
if ("netscape|gecko|opera".IndexOf(this.Request.Browser.Browser.ToLower())
this.ClientTarget = "Uplevel";
}

-- bruce (sqlwork.com)
 

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