Monday, October 29, 2012

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException

While working on Asp.Net application with Master Pages, Child pages and web user controls getting following error is very common. Which is related to Events related to Web user controls, e.g. Button click event...

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument.  Event validation is enabled using  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.

In such cases as error says we simply have to disable EventValidation in @Page directive and error disappears.

<%@ Page EnableEventValidation="false" %>
OR enable it for whole application by modifying it in web.config file

<%@pages enableeventvalidation="false">
<%@/pages>
Submit this story to DotNetKicks

Read more...

Thursday, August 9, 2012

Auto Generate Serial Number in GridView

To auto generate serial number in Gridview, which we can use only for display purpose and has nothing to do with database and data related operations.

  • Add Following Column in Grid View at first position

       
       <%# ((GridViewRow)Container).RowIndex + 1%>
   
 

Above code will simply autogenerate serial number in Gridview
Submit this story to DotNetKicks

Read more...

Wednesday, August 1, 2012

Textbox with background image using CSS

We can use CSS To make stylish textboxes like rounded corner textbox or textbox with some image inside. Rounded corner text box is like following image.


To make rounded corner textbox we use following logic. We will put textbox in some wrapper layer i.e. div tag and apply style to wrapper layer.
Now style applied to wrapper div tag is as follows
.tt-wrapper
 {
 background-image:url('images/user_box.png');
 margin:0;
 width:255px;
 height:35px; 
  }
In above style user_box.png is a background image (check following image.)


 Then we apply style to fit the textbox with in wrapper div class.
.tt{
 width:240px;
 height:25px;
 margin:5px 0 0 8px;
 border:none;
 background:none;
 }
And we are done with Textbox with rounded corner. To display some image inside textbox we simply need to add background image in the class applied to textbox
Submit this story to DotNetKicks

Read more...