Manish Pansiniya's Blog

.NET, C#, Javascript, ASP.NET and lots more…:)

Posts Tagged ‘ASP.NET

element style cannot be nested in div–ASP.NET Masterpage

leave a comment »


You can create another Content Place Holder in master page

<asp:ContentPlaceHolder ID="Head" runat="server">

Then in pages, you need to put two content place holder and put your stylesheet and script in Head place holder.


Written by Manish

December 4, 2010 at 2:42 pm

Add Custom Message to ValidationSummary in ASP.NET

leave a comment »


Following is the code you can write to put the message in validation summary while doing validation on button or on another event.

CustomValidator val = new CustomValidator();
val.IsValid = false;
val.ErrorMessage = "Custom error message to add to the ValidationSummary";

Written by Manish

November 24, 2010 at 6:20 pm

Literal content is not allowed within skin file

leave a comment »

We have following errors in our project

Literal content (‘<gv:TwoHeadedGridView SkinID="gv"  EmptyDataText="No Record(s) Found."  AllowPaging="true" PageSize="10" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt">  </gv:TwoHeadedGridView>’) is not allowed within a ‘skin file’.

The problem here is, we missed runat=server attribute. Simple 🙂

[tweetmeme only_single=”false”]

Written by Manish

October 5, 2010 at 2:45 pm

Threading in ASP.NET

leave a comment »

You can do the same method which we can do in form based application. You need to be sure about the logic you are doing in the Thread.

Suppose you are accessing, Session in the thread and if thread is taking longer while the page code’s Response ended. Then you have problem as when response is ended the session variable of request is cleared.

So if you are accessing Request.Session , it will show null value after response is added.

You might call thread on page.init and in page load, you can call Join to wait for thread to complete and go ahead.

Below is sample code: I have passed context as thread’s parameter. It will be used fully as I used Join of thread. If I do not use Join then some of the variables is not available in context parameter. The conclusion is we can use thread same way but we need to be sure of page parameters/context parameters which we are passing to thread. That’s it!!!

protected void Page_Load(object sender, EventArgs e)
        Thread t = new Thread(new ParameterizedThreadStart(ref CallAnalyticsFunction));

        Response.ContentType = "image/gif";
        Response.AppendHeader("Content-Length", _imgbytes.Length.ToString());

[tweetmeme only_single=”false”]

Written by Manish

October 3, 2010 at 4:06 pm

Server Tags <%…%>

leave a comment »

<% %> An embedded code block is server code that executes during the page’s render phase. The code in the block can execute programming statements and call functions in the current page class.

<%= %> most useful for displaying single pieces of information.

<%# %> Data Binding Expression Syntax.

<%$ %> ASP.NET Expression.

<%@ %> Directive Syntax.

<%– –%> Server-Side Comments.

Written by Manish

November 10, 2009 at 11:57 pm

Posted in .NET, .NET 3.0

Tagged with , ,