views:

340

answers:

1

Hi,

I know there is already another post on StackOverflow (here) but it doesn't exactly address my issue. I would like to use the HTML button element () on ASP.net wherefore I've created a custom server control for rendering such. The reason for using a button is mainly to be able to create an image button. You could now argue to use CSS and JavaScript etc to "simulate" an image button. Well the problem is that one of the main requirements is that the site has still to run without JavaScript for accessibility reasons.

Theoretically the approach of using a HTML button element would work, but there is the problem of the IE which uses the content of the button as postback value. This is a major problem since it raises an error on IE plus it is somehow a performance killer to send the whole img tag content back to the server. The error thrown at runtime could be avoided by setting the page's ValidateRequest to false. This is however not desirable since the new server control will be used by many programmers which wouldn't want to add this to all of their pages.

So my question is whether there is a possibility of influencing the postback value or whether this is a pure browser decision. Btw. I cannot rely on my users to just use Firefox or IE8 (which I heard apparently fixed this problem).

Thanks a lot for any help.

A: 

You might be able to hack it with JavaScript, but the reliable approach is to ignore the value and make use of the name attribute.

http://www.dev-archive.net/articles/forms/multiple-submit-buttons.html covers this with examples in a couple of languages.

David Dorward
Sorry but I cannot rely on JavaScript, otherwise I would have solved it already. I highlighted it now on my post..
Juri
I only mentioned JavaScript as an aside. The suggested solution doesn't use it.
David Dorward
hmm...ignoring the value wouldn't be an issue for me and could possibly work. But the major problem is that since IE posts the whole content, so possibly also HTML tags (if images are included), the Asp.net server will raise an exception due to the EventValidation that takes place, notifying that a possibly dangerous content has been submitted. Of course I could disable this, but just on page level and that's not desirable.
Juri