Skip to content

RegisterForEventValidation can only be called during Render() .net error

November 10, 2010

The following error cause due EventValidation.
RegisterForEventValidation can only be called during Render() ;

we can fix  this error in a simple manner. just add  EnableEventValidation=”false” in your page tag of the ASPX page.

if you feel very hard to find just add this tag below the Page tag

<%@ Page EnableEventValidation=”false” %>

Hope this will solve the issue.

Happy coding.


SQL server 2005 Select value with Replace

September 22, 2010

Hai all,
here i am going to show how to replace some special characters from the SQL server 2005 select query.

select replace(replace(replace(replace(replace(ColumnName,'(‘,”),’)’,”),’#’,”),’&’,”),’/’,”) from yourTableName;

this above query will replace some special characters like(#,&,(,),/). it will be more helpfull if we need to replace many characters from single Column value.

Same way we can replace any characters for a string.

for example we can replace a string value Lips to Loves by using the below SQL Query.

select replace(ColumnName,’lips’,’Loves’) from TableName

I hope this will help some one.

Happy Coding. Authentication Required Popup in Firefox and IE

August 25, 2010

I have sometimes found problems with ‘broken permission chains’ in Windows whereby some of the lower level directories are not set to inherit the permissions of the parent, and this then leads to authentication issues. You can try the following:

Navigate to root web directory in windows explorer, right-click and select ‘properties’
Select the security tab, and click the ‘advanced’ button
Check the checkbox labelled something like ‘replace all entries on child objects with entries shown here’
Click OK, and OK again on the previous window, and try again.

This will solve the issue.
Happy coding. dynamic menu without XML

August 6, 2010
I’m going to provide a simple example how to display hierarchical data from SQL Server Database  in the Menu. A requirement is that the implementation should not be dependant on the hierarchy level in the database. It means that the Menu implementation should be capable of displaying data from any level, no matter how deep.

Let’s assume we have SampleDB database with the SampleCategories table as follows.
Table Categories with columns ID,ParentID,CategoriesName.
All my parent Categories will have parentID as 0. all child Categories will have corresponding  Categories ID as parentID.
<asp:Menu id=”Menu1″  Orientation=”horizontal” runat=”server” BackColor=”Transparent” CssClass=”menuParent”  StaticEnableDefaultPopOutImage=”false”
DynamicHorizontalOffset=”0″ Font-Names=”Garamond” StaticSubMenuIndent=”5px” StaticDisplayLevels=”1″>
<StaticMenuItemStyle HorizontalPadding=”5px” VerticalPadding=”2px” Font-Size=”Small” Font-Bold=”true” />
<DynamicMenuStyle CssClass=”adjustedZIndex” HorizontalPadding=”6px” BackColor=”Transparent” />
<DynamicMenuItemStyle ItemSpacing=”2px” VerticalPadding=”2px” BackColor=”Transparent”/>
We want to populate the root level. Here’s the code.
private void PopulateMenu()
DataTable menuData = GetMenuData();
private DataTable GetMenuData()
string selectCommand = “SELECT CategoryId,ParentId,categoryName FROM category”;
string conString = System.Configuration.ConfigurationManager.ConnectionStrings[“SQLConnString”].ToString();
SqlDataAdapter dad = new SqlDataAdapter(selectCommand, conString);
DataTable dtblCategories = new DataTable();
return dtblCategories;
private void AddTopMenuItems(DataTable menuData)
DataView view = new DataView(menuData);
view.RowFilter = “ParentID=0”;
foreach (DataRowView row in view)
MenuItem newMenuItem = new MenuItem(row[“categoryName”].ToString(), row[“CategoryId”].ToString(), “”,””, “_parent”);
//newMenuItem.Selectable = false;
newMenuItem.NavigateUrl = “#”;
AddChildMenuItems(menuData, newMenuItem);
private void AddChildMenuItems(DataTable menuData, MenuItem parentMenuItem)
DataView view = new DataView(menuData);
view.RowFilter = “ParentID=” + parentMenuItem.Value;
foreach (DataRowView row in view)
string subCatName = Convert.ToString(row[“categoryname”]);
MenuItem newMenuItem = new MenuItem(row[“categoryName”].ToString(), row[“CategoryId”].ToString(), “”, “~/Store.aspx?cID=” + row[“CategoryId”].ToString(), “_parent”);
AddChildMenuItems(menuData, newMenuItem);

Thats it now you got New Dynamic Horizontal menu.

Note for IE8:

please add the follwoing CSS in you page.

<style type=”text/css”>



z-index: 1;


</style> Email with Images

April 5, 2010

This is very simple code to send Email with images.  Here i’m going to demo how to send a email with image within the email body. its not an attachment image. the image will paced inside email body. in this example i used html as string. its very easy to design email body.

here in this string Html we need to use Escape sequence for every “”(example: img tag alt must be like  alt=\”abczs\”).

also don’t forget to use the below name space to send email. This is very important  <img src=’; /> same way you can add any number image.

<% @Import Namespace=”System.Web.Mail” %>

MailMessage msgMail = new MailMessage();

msgMail.To = “”;

msgMail.Cc = “myfriend@in.Com”;

msgMail.From = “”;

msgMail.Subject = “Email with Images”;

string body = “<table width=”600″ height=”600″ border=”0″ align=”center” cellpadding=”0″ cellspacing=”0″ id=”Table_01″><tr><td width=”600″ height=”176″ align=”left” valign=”top”> <img src=’; border=0 hspace=0 alt=”headerimage”” />This is sample email from {username}.</td>  </tr>”;

body = body.Replace(“{username} “, “Firstnametextbox.text”);

msgMail.IsBodyHtml = true;
SmtpClient mailSender = new SmtpClient(“localhost”); //use this if you are in the development server else use your mail settings from web config.

we can embed images in emails with LinkedResource and AlternateView. i don’t think its very easy so i choose this ways. but never say its an wrong way of emailing. for simple process i used this email format.

Happy coding.

Top 10 Sites

February 25, 2010
tags: ,

Here i post one of the top 10 sites which is more useful for a freshers. we can create free account except the last one. also we can post our Questions  to get any suggestions.
These site provide a wide solution for our daily errors.

If any one have more sites better then this list,please post here.

    2. codeproject
    3. beansoftware
    4. dotnetspider
    5. c-sharpcorner
    6. dotnetfunda
    7. dynamicdrive
    8. w3schools
    9. developerfusion
    10. experts-exchange

Hello world!

February 25, 2010

Welcome to This is your first post. Edit or delete it and start blogging!