_DotNetStuff and more...

Thursday, July 31, 2008

Sys.WebForms.PageRequestManagerServerErrorException: 500

Sys.WebForms.PageRequestManagerServerErrorException:An unknown error occured while processing the request on the server.The status code returned from the server was:500

The real error was:
Invalid postback or callback argument. Event validation is enabled using;<pages enableeventvalidation="true"/>; in configuration or <@ Page EnableEventValidation="true" %/>; in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

The fix for me:
EnableEventValidation="false"

Image(img) doesn't show up on initial page load, FireFox 2.0.0.16

Here is the tag <img src="images/exampleLogo.gif" />, what is wrong with it? Well, it depends on the browser and DOCTYPE and CSS being used. In this case I was using FireFox 2.0.0.16 , DOCTYPE http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd and some CSS to center my DIV on the screen. The result was that using the img tag without the width and height defined resulted in the image not showing up unless I refreshed the screen. I have had this same issue with Javascript img rollover scripts as well. The reason this happens is because the width and height are not defined.

Does not work:
<img src="images/exampleLogo.gif" />

Works:
<img src="images/exampleLogo.gif" width="100" height="30" />

The DTD(see below for img definition) does not require these attributes, however this is the second time I have seen this issue.

DTD definition for img tag:

<!ELEMENT img EMPTY>
<!ATTLIST img
%attrs;
src %URI; #REQUIRED
alt %Text; #REQUIRED
name NMTOKEN #IMPLIED
longdesc %URI; #IMPLIED
height %Length; #IMPLIED
width %Length; #IMPLIED
usemap %URI; #IMPLIED
ismap (ismap) #IMPLIED
align %ImgAlign; #IMPLIED
border %Length; #IMPLIED
hspace %Pixels; #IMPLIED
vspace %Pixels; #IMPLIED
>

Monday, July 28, 2008

Validate ASP.NET controls independently from one another

I had a page that had form validation and then additional validation in a modal state. They needed to validate independently. Short of having a true validation framework in place ASP.NET provides Validation Groups to meet these needs. The link below has a great example and explanation of how it works.

http://msdn.microsoft.com/en-us/library/ms227424.aspx