Archive | October 2008

IE innerHTML – "Unknown runtime error"

Setting value of <div id=”divhtml”> using js like this :

document.getElementById(“divhtml”).innerHTML = “<form><input type=”text”>…</form>”;

it was giving me error..


oldDiv = document.getElementById(divhtml);
newDiv = document.createElement(oldDiv.tagName); =;
newDiv.className = oldDiv.className;
newDiv.innerHTML = “<form><input type=”text”>…</form>”;

oldDiv.parentNode.replaceChild(newDiv, oldDiv);

And it worked like a charm!!!!!!

Link :

There was an error while trying to serialize parameter The InnerException message was ‘Type ‘System.Collections.Generic.List`1[Employee, Version=, Culture=neutral, PublicKeyToken=null]‘ with data contract name ‘ArrayOfEmployee:’ is not expected. Add any types not known statically to the list of known types – for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.

Hi if you are getting your hands dirty with WCF and got your mind blown up with the error as shown above or shown in Screen i have medicine of go ahead!!!!


I am creating one simple serviceoperation which should take argument as an object but i will pass instance of my generic list which can be like List<Employee> or List<Person> and all this….because in service implementation i will do further operation based on type….I have created one application like this:









Now when i run this application it gives me error of KnownTypeAttribute and serialization


Actually root cause of problem is that we have defined object as our datacontract but when we pass List<Employee> or List<Person> it dosen’t knows what to serialize and send from wire…..hoohh…….simple if i have told you to say HI and it i will sat Bye…you can’t understand what i mean to say…so i need to help you in understanding Bye…Simple!!!!!so let us tell CLR that hey what to do if i pass List<Employee> or any type which i want to pass..


Open your service contract IService.cs

and after [ServiceContract] Add [ServiceKnownType(typeof(List<Employee>))] or [ServiceKnownType(typeof(List<Person>))]….and Run the application…modified IService.cs looks like this:


Hope it helped you…Wants to say..Thanks say it to

Sowmy Srinivasan’s for nice and in-depth article:


I am just wondering suppose if i have 50 Types which i want to pass then i need to declare all this on top of IService….just searching some alternative for it..if i found will let you know and hoping for the same….

Adding application relative path in head section of master Page for JavaScript


I have my application structure similar to as shown below:


My JavaScript file has one function which I want to use on each and every page which used my master page. That JS function looks like:

<font size="2">function HelloWorld()
&nbsp;&nbsp;&nbsp; alert("Helloo.....World...");
<font size="2">

And to register a JS file i have registered it on one place which is in MASTER..rather than registering it on each and every page. so my master head looks like this:

<font size="2">
<head runat="server">&nbsp;&nbsp;&nbsp; </font> 

<font size="2"><script language="javascript" type="text/javascript" src="Javascript/HelloWorld.js">
<font size="2">

on FormWithMasterPage.aspx. i was calling that function as shown below:

<font size="2"><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" value="OK" onclick="HelloWorld();" />
<font size="2">

And it was working as expected..means showing alert message:


but when i tried the same within SubPageDefault.aspx which is under my SubFolder folder it was throwing an error:


Which says that it was unable to find JS function HelloWorld();

In short..How to Add application relative Javascript reference?????

Because for SubPageDefault.aspx function it was trying to find "Javascript/HelloWorld.js" under /SubFolder/javascript/..


To solve this problem you need to change bit in your master page head section:

1. Open master page and locate its <HEAD> Section and if it has runat="server" remove it. [In some case if you are using Themes then it is compulsory to put problem put another head tag with no runat="server".]

2. Hook the code as shown below under <HEAD> for registering JS:


<font size="2">
</font><font size="2">
<font color="#0000ff">&nbsp;&nbsp;&nbsp;
<%--To use line as shown below remove runat="server" And if it is required to put runat="server" put one more head with runat="server"--%>
<script language="javascript" type="text/javascript" src='<%=ResolveClientUrl("~/Javascript/HelloWorld.js")%>'></script></font>
&nbsp;&nbsp;&nbsp; </font>
<font size="2"><font color="#ff0000"><%--Line below will not work--%>
 <%--<script language="javascript" type="text/javascript" src="Javascript/HelloWorld.js"></script>--%>
<font size="2">

That's it...Happy mastering!!

Source code:

Links: - ATOZ of Master Page

Web.config registration missing! The Telerik dialogs require a HttpHandler registration in the web.config file.


Was getting this error with IIS7 and Telerik Dialog control. Which says that “Web.config registration missing! The Telerik dialogs require a HttpHandler registration in the web.config file.”


Telerik guys says “When a web site is running under IIS7 Integrated mode, the web server searches the HttpHandler registrations under the <system.webServer> configuration section instead of the standard <system.web> configuration section of the application configuration file.”.

All you need to do to manually register the HttpHandler for the IIS7 Integrated mode is copy the Telerik HttpHandler to the <handlers> section of the <system.webServer> section group, delete the validate attribute and give it a name, e.g.

<add name="Telerik.Web.UI.DialogHandler" path="Telerik.Web.UI.DialogHandler.aspx" verb="*" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI" />

Thanks to :

Log4Net – Quickstart guide

Q.What it is?

Ans. It is a logging framework for Microsoft .NET. The initial work was done by NeoWorks and was donated to Apache Software foundation in February 2004.

It is a tool which will help programmers to output a log to a variety of output targets. [Text file, eventLog, database etc.]

Provides Nested Diagnostic Context (NDC) and Mapped Diagnostic Context (MDC).

Log4 net is designed with two main goals: speed and flexibility.


  • Supports for multiple frameworks
  • Output to Multiple Logging Targets
  • Hierarchical logging architecture
  • XML Configuration
  • Dynamic Configuration
  • Logging Context
  • Proven Architecture

Q. Developing Application using Log4NET.

In this demo Application we will see how we can write a log to the text file. This has been configured in Web.config

1) Create a new console Application


2) Add Reference to Log4net.dll [I guess you have downloaded the Log4NET project. If not then please download from here: And you will get bin\net\2.0\ log4net.dll this is the guy whose reference we are going to add]…and ya don’t forget to include using statement using log4net; and using log4net.config;

3) Add Configuration file


4) Now add the following stuff in your configuration file.

<?xml version="1.0" encoding="utf-8" ?> 
<!--Configure your configuration Section Handler which is Log4NetConfigurationSectionHandler--> 
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/> 
<!--Only one root logger element may only be defined and it must be a child of <log4net> 
element. The root logger is the root of the logger hierarchy. All loggers ultimately inherit from this logger.--> 
<!--Root Element has no attributes--> 
<level value="DEBUG" /> 
<!--Optional element, maximum of one allowed. Defines the logging level for this logger.  
This logger will only accept event that are at this level or above.--> 
<appender-ref ref="LogFileAppender" /> 
<!--Zero or more elements allowed. Allows the logger to reference appenders by name.--> 
<!--Appenders may only be defined as child elements of the <log4net> 
element. Each appender must be uniquely named. The implementing type for the appender must be specified.--> 
<!--name = Required attribute. Value must be a string name for this appender.  
The name must be unique among all the appenders defined in this configuration file. This name is used by the <appender-ref> 
element of a Logger to reference an appender.--> 
<!--type = Required attribute. Value must be the type name for this appender.  
If the appender is not defined in the log4net assembly this type name must be fully assembly qualified.--> 
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" > 
<!--RollingFileAppender extends FileAppender to backup the log files when they reach a certain size.--> 
<param name="File" value="C:\log.txt" /> 
<param name="AppendToFile" value="true" /> 
<rollingStyle value="Size" /> 
<maxSizeRollBackups value="10" /> 
<maximumFileSize value="10MB" /> 
<staticLogFileName value="true" /> 
<!-- layout = Optional element, maximum of one allowed. Defines the layout used by this appender.--> 
<layout type="log4net.Layout.PatternLayout"> 
<param name="ConversionPattern" value="%-5p%d{yyyy-MM-dd hh:mm:ss} - %m%n" /> 
<!--%p - will show the level of message 
%d - will show the date 
%l - will show the class, method and line number where error occurred and  
%m - will show message to display 
See more pattern from Here 

This configuration says that I want to write a log in C:\log.txt file. And it should be appended…Will explore more on each bit and write it down..but for this point of time I don’t think it is required.

5) Now we are ready with configuration part so let’s log something.

Open your program.cs file and declare this variable

/*CREATE A LOGGER - you can create different Logger for each Package/namsepace

* No need to create Logger for each Class.


public static readonly ILog logger = LogManager.GetLogger(typeof(Program));

Now under Main let’s use this logger to log


//Write down Error/Debug/Fatal/Information Message

logger.Debug("..This is Debug Message...");

logger.Error("..This is Error Message...");

logger.Fatal("..This is Fatal Message...");

logger.Info("..This is Information Message...");

So, finally your main looks like this:


6) Run the application. Close the console which get opened. And locate c:\log.txt file. Which we have configured on step 4.

7) If you can see the following output then its good time to think about starting using it within your project.





log4net 1.2.10


MS Logging Block And Log4net

Configuration information



Nice resource with all information

using Object Initializers with Sub object

I have Two Entities like as shown below:





Now i want to use Powerful feature of C# 3.0 object initializers. I am using it since few days but with simple types not with complex type like Employee.Address.. but its good to know that c#3.0 also supports this…Thanks to “Anders hejlsberg” for such a nice programming language…anyway lets look how we can do’s the way..


and output is:


My intention of showing output is that the code works :) just kidding… Enjoy the new and powerful features of C#3.0…

Fetching value from XML parameter in SP-SQL SERVER 2005

XML Document as a parameter

[sourcecode language='xml']

DECLARE @xmlParam as XML

SET @xmlParam =












































SQL Syntax for retrieving values:


–get the ID

ParamValues.Data.value(‘ID[1]‘,’bigint’) as ID,

–get the Cost

ParamValues.Data.value(‘Cost[1]‘,’decimal(10,2)’) as Cost,

ParamValues.Data.value(‘Active[1]‘,’bit’) as Active –Active


–get the data from entityfields using Xquery

@xmlParam.nodes(‘Root/List’) as ParamValues(Data)



Updated on 10-Oct-2008

At a time of Update…How to fetch values??

DECLARE @employeesData as XML

SET @employeesData =

UPDATE Employees
SET [EmployeeName] = ParamValues.Data.value(‘EmployeeName[1]‘,’varchar(50)’)
FROM @employeesData .nodes(‘/Employees/Employee’) as ParamValues(Data)
WHERE EmployeeID IN (ParamValues.Data.value(‘EmployeeID[1]‘,’bigint’))

Hope it helps some one…..runing out of time..

EXECUTE permission denied on object ‘ABC’, database ‘XYZ’, schema ‘dbo’.


EXECUTE permission denied on object ‘usp_GetEmployeeDetails’, database ‘Employee’, schema ‘dbo’.


  1. Expand your database Node. For me it’s “Employee”.
  2. Underneath of it Expand “Security” Node.
  3. Click on the user which you are using for Database operations. By default it is


  1. It will open the window as shown below from database Roles Select db_owner:


That’s it…


Get every new post delivered to your Inbox.

Join 250 other followers