Blog:DotNet runat="world" creator="Vaijayanta"

Google Brother Up


Difference between Mutable & Immutable objects

The difference between mutable and immutable objects is that, string buffer is a mutable string object, where as a string is a non-mutable object. Mutable basically means changeable any time.

In object-oriented computer programming an immutable object basically is an object which cannot be customized after it is formed. This is opposition to a mutable object, which can be customized after is formed. A particular object can either be completely immutable or a certain attributes in that particular object may be acknowledged as immutable, like applying the const element data attribute in the C++ programming language.

In certain cases, an article is thought to be immutable even while certain internally applied attributes modify but the object's state come into view as unchanging from and peripheral point of view.

315 unique visitors

Some Interview Question Answers (Part 002)

1. Which is one of the access modifiers in .NET?

Public, Protecte, Private, Internal

2. What does GAC stand for in .NET?

Global Assembly Cache

3. Which object contains its items in key/value pairs?

Sorted List and Hash Tables

4. Structures do not support inheritance, while Classes support it.


5. If AutoGenerateColumns property is set to True and custom column definitions are still provided, GridView will render both of them.


6. What is the property name of a GridView (or a DataGrid) that regulates the sorting?

AllowSorting = true

7. A single .NET dll can contain 1024 classes at most.


8. ADO.NET is entirely based on XML.


9. Which is one of the authentication types in .NET?

Passport Authentication

10. What is the extension of a Web User Control?


313 unique visitors

Some Interview Question Answers (Part 001)

1. What is the lifespan for the information stored in a ViewState?

Exists for the life of the current page

2. What section of a Web.Config is used to store a list of authorized users?


3. Which object contains the user name in an ASP.NET form page?


4. Which one is triggered first in an ASPX page cycle?


5. What is the top .NET class that everything is derived from?


6. Literal control always encloses its text value with SPAN tags.


7. Which one of the following statements is false?

Arrays can be changed in size at runtime without ReDim.

8. ASP.NET still recognizes the global.asa file.


9. What is the default Session Timeout?

20 minutes

10. C# supports multiple inheritance by using classes.


313 unique visitors


Differences between nvarchar and varchar in SQL Server

SQL Server provides both datatypes to store character information. For the most part the two datatypes are identical in how you would work with them within SQL Server or from an application.

The difference is that nvarchar is used to store unicode data, which is used to store multilingual data in your database tables. Other languages have an extended set of character codes that need to be saved and this datatype allows for this extension. If your database will not be storing multilingual data you should use the varchar datatype instead. The reason for this is that nvarchar takes twice as much space as varchar, this is because of the need to store the extended character codes for other languages.

271 unique visitors


Cross-Site Scripting & Remediation Action

Cross-Site Scripting
Cross-site scripting is a term used to describe problems which arise when maliciously crafted user data causes a web application to redirect an unsuspecting web browser to an undesired site. It was possible to send strings with special HTML characters ( < > " ' ) to your web application, and see them rendered in the response. Since these characters were not encoded by the web application, it may be possible to inject HTML scripting code into the rendered page. The injections can occur in your HTML body, Title, Scripting, or even commented out portions of the document. Note: Due to the potential negative impact on this web server's resources that could result from attacking a large number of cross-site scripting attack vectors, TrustKeeper abandons this test after it has found at least three instances where user input is not being properly sanitized. Therefore, it is possible that the reported findings associated with this vulnerability are only a subset of all possible attack vectors.

Remediation Action
This is a generic warning based on a test that indicates that your web application may not validate user-provided input, such as that provided by a form. Review your web application to ensure that user data is checked on the server side of the application (NOT in the web browser) for proper length and character content. It is recommended that a white-list of acceptable characters be used, with all other characters being HTML encoded prior to being sent in response to the client. Review the "Cross-Site Scripting", "Data Validation", and "Review Code for Cross-site scripting" pages on (see the reference links in this finding).

256 unique visitors

C# Code to Dynamically Change Title of a Page

C# Code to Dynamically Change Title of a Page: -

[title]My Website - [%=Request.QueryString["Mode"]%] form[/title]

* Replace the [ by <>

256 unique visitors


Website - Great Site for Learning Serialization to XML - XmlSerializer

236 unique visitors

Website - Sorting of String by Array / LINQ / Lists

236 unique visitors

A different way to insert Data into a Gridview from array

strProjListFinal = strAERProjList.Trim() + ";" + strIAProjList.Trim();
string[] strs = strProjListFinal.Split(';');
foreach (string s in strs)
ddlProjectName.Items.Insert(0, new ListItem("All Projects", "-1"));

236 unique visitors


Website to get conversion techniques of DATETIME in sqlserver

To understand difference between




The website is: -

234 unique visitors

SQL Server - Create Temporary Tables & Insert into Temporary Table

DECLARE @tbl table
ID int identity,
ProjName varchar(100)
INSERT into @tbl(ProjName)
SELECT * from dbo.SemisvToString(@IAAudioEyeProjectNames)


ProjectName varchar(200),
TaskName varchar(400), --'CHANGED THIS 200 to 400 '
HoursSpent decimal(18,2),
ExecutionDate varchar(20),
UserName varchar(200)


INSERT INTO #AERTTV2TempReportTable(ProjectName, TaskName, HoursSpent, ExecutionDate, UserName)
SELECT ProjectName, TaskName, HoursSpent, CONVERT(VARCHAR(20),ExecutionDate,101) AS ExecutionDate, UserName
FROM AudioEyeReporting.dbo.TempReportTable
WHERE IsDeleted = 0 AND ExecutionDate BETWEEN @StartDate AND @EndDate
SELECT ProjectName, TaskName, HoursSpent, CONVERT(VARCHAR(20),CONVERT(DATETIME,ExecutionDate),101) AS ExecutionDate, UserName
FROM TimeTrackerV2.dbo.TempReportTable
WHERE ProjectName IN (SELECT ProjName FROM @tbl) AND ExecutionDate BETWEEN @StartDate AND @EndDate


SELECT SUM(HoursSpent)
FROM #AERTTV2TempReportTable

234 unique visitors

SQL Server - Function to Get individual values from Comma Separated Values (CSVs)

1. CSV - String

CREATE FUNCTION[dbo].[CsvToString] ( @Array VARCHAR(1000))
(StrValue VARCHAR(1000))
DECLARE @separator CHAR(1)
SET @separator = ','
DECLARE @separator_position INT
DECLARE @array_value VARCHAR(1000)
SET @array = @array + ','
WHILE patindex('%,%' , @array) <> 0
SELECT @separator_position = patindex('%,%' , @array)
SELECT @array_value = left(@array, @separator_position - 1)
INSERT @StrTable
VALUES (Cast(@array_value as VARCHAR(1000)))
SELECT @array = stuff(@array, 1, @separator_position, '')

2. CSV - Int

CREATE Function [dbo].[CsvToInt] ( @Array varchar(1000))
returns @IntTable table
(IntValue int)
declare @separator char(1)
set @separator = ','
declare @separator_position int
declare @array_value varchar(1000)
set @array = @array + ','
while patindex('%,%' , @array) <> 0
select @separator_position = patindex('%,%' , @array)
select @array_value = left(@array, @separator_position - 1)
Insert @IntTable
Values (Cast(@array_value as int))
select @array = stuff(@array, 1, @separator_position, '')

3. SSV(Semicolon Separated Values) - Int

ALTER FUNCTION[dbo].[SemisvToString] ( @Array VARCHAR(1000))
(StrValue VARCHAR(1000))
DECLARE @separator CHAR(1)
SET @separator = ';'
DECLARE @separator_position INT
DECLARE @array_value VARCHAR(1000)
SET @array = @array + ';'
WHILE patindex('%;%' , @array) <> 0
SELECT @separator_position = patindex('%;%' , @array)
SELECT @array_value = left(@array, @separator_position - 1)
INSERT @StrTable
VALUES (Cast(@array_value as VARCHAR(1000)))
SELECT @array = stuff(@array, 1, @separator_position, '')

234 unique visitors


Data does not show when updated windw is reopened

Suppose I am opening a new window with and saving some changes in the window and closing the window. When I reopen the window it shows the previous values. (It display data which had appeared before the changes) after refreshing only I am getting recent data. I need new data only while opening the window.

To solve this we do: -

Response.Cache.SetCacheability(HttpCacheability.NoCache) will have to be put on onload()

Javascript code to refresh the page called window.refresh() will not work here.

212 unique visitors


Code to embed a flash file in a .NET application

{object width="250" height="400"
{param name="movie" value="mp3player.swf" /}
{embed src="mp3player.swf" width="250" height="400"
  type="application/x-shockwave-flash" pluginspage=
  "" /}

205 unique visitors

Alert Message using Response.Write in Web through C# Code

1) Hardcoded Alert


2) Variable Alert

string txtName = "Hello " + txtText.Text;
Response.Write("{script}alert('" + txtName + "');{/script}");

205 unique visitors


Required Field Validator does not fire in Firefox - Solution

Always write code under Page.IsValid scope if Required Field Validator does not fire in Firefox but fires in IE.

       if (Page.IsValid)
            // code
 catch (Exception ex)
       string msg = ex.Message;

203 unique visitors


SET NOCOUNT ON; - Improve performance of stored procedure

Benefit: - By Setting NOCOUNT as ON we improve the performance of the stored procedure

Problem: -
One of the biggest things that DBAs try to do on a daily basis is to ensure that their database systems run as fast as possible.  As more and more users access the databases and the databases continue to grow, performance slow downs are almost inevitable. Based on this, DBAs and developers should do everything they possibly can to keep performance related issues in mind early in the database lifecycle.  This is not always easy to do, because of the unknowns and the changes that occur over time, but there are some simple things that can be done and we will touch upon one of these in this tip.

Solution: -
Sometimes even the simplest things can make a difference.  One of these simple items that should be part of every stored procedure is SET NOCOUNT ON.  This one line of code, put at the top of a stored procedure turns off the messages that SQL Server sends back to the client after each T-SQL statement is executed.  This is performed for all SELECT, INSERT, UPDATE, and DELETE statements. Having this information is handy when you run a T-SQL statement in a query window, but when stored procedures are run there is no need for this information to be passed back to the client.

By removing this extra overhead from the network it can greatly improve overall performance for your database and application.

If you still need to get the number of rows affected by the T-SQL statement that is executing you can still use the @@ROWCOUNT option.  By issuing a SET NOCOUNT ON this function (@@ROWCOUNT) still works and can still be used in your stored procedures to identify how many rows were affected by the statement.

Microsoft even realized the issue that this creates and has changed the stored procedure templates from SQL Server 2000 to SQL Server 2005.

Here is the old template style available in SQL Server 2000 without the SET NOCOUNT ON.

192 unique visitors


A potentially dangerous Request.Form value was detected from the client... (Solution - Solved)

When you come across an error saying "A potentially dangerous Request.Form value was detected from the client..." you can be very sure that you need to do 2 things to solve it.

1) Set the aspx page set ValidateRequest="false" so that the page directive looks like this: - {%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddPressRelease.aspx.cs"
Inherits="AddPressRelease" ValidateRequest="false" %}

2) While submitting the page inside the submit method html encode all textboxes like below: -

objPressReleaseBO.Title = Server.HtmlEncode(txtTitle.Value);
objPressReleaseBO.Description = Server.HtmlEncode(txtDescription.Value);

Your problem will be solved. :)

186 unique visitors


Readonly Textbox - Error Solve - sans Javascript

How to Solve: -
1) Error in getting the value of a read only textbox in
2) Create a readonly textbox without using Javascript.

1) When u add a text box as: -

{asp:TextBox ID="txtDate" runat="server" ValidationGroup="Submit" ReadOnly="true" Text="" TabIndex="2" /}

2) and try to get the value of the textbox in code behind as: -

objPressReleaseBO.Date = Convert.ToDateTime(txtDate.Text);


Error Occurs: String was not recognized as a valid DateTime.


the value Text of the text box cannot be read by the control


1) take an html textbox {input runat="server" type="text" name="txtDate" id="txtDate" value="txtDate" tabindex="2" readonly /}

2) capture the value of the textbox from code behind as

objPressReleaseBO.Date = Convert.ToDateTime(txtDate.Value);

Solved: - 

1) Then the text box becomes read only
2) Also the value of the textbox is possible to capture from code behind.

179 unique visitors


Difference between a Label and a Literal in ASP.NET

1. Label is heavy weight so increases size of page while literal is light weight, so decreases size of page.
2. Label supports cssclass property but literal does not support cssclass property.
3. Label cannot be used to insert html code directly but literal can be used to insert html code directly so dynamically html tags can be created.
4. When AssociatedControl property is set, Label produces an html label as its output but when AssociatedProperty is omittedm then Label text will be wrapped in a span.

For more help refer:

177 unique visitors

Drop Down List