DotNet Blogs

Articles of ASP.NET, C# & SQL Server

Use Popupcontrolextender as dropdownlist

Posted by Sujit Kumar on May 18, 2009

code1

You can also use ListBox as popup 

 2

Posted in .NET, asp.net | Tagged: | 1 Comment »

how to hide url in status bar

Posted by Sujit Kumar on May 15, 2009

1.

<a href=”http://www.websitename.com/?parm=12” onMouseOver=”window.status=’http://www.websitename.com’;return true” onMouseOut=”window.status=””>Click here </a>

 

2.

<script language=”javascript” type=”text/javascript”>     function redirect(URL)     {       document.location=URL;       return false;     }    </script>

<a href=”http://www.websitename.com” onclick=”returnredirect(‘http://www.websitename.com/?parm=12′);”>Click here</a>

Posted in asp.net, java script | Tagged: | Leave a Comment »

Hide Context menu of Browser

Posted by Sujit Kumar on May 15, 2009

using oncontextmenu event of body, you can hide context menu of any Browser:

ex:

<body oncontextmenu =”return false;”>

</body>

Posted in asp.net, java script | Tagged: , | Leave a Comment »

disable the default button on a webform

Posted by Sujit Kumar on March 18, 2009

you can disable default button on a webform set to false of button property “UseSubmitBehavior”  .

ex:

 

<asp:Button ID=”btnSave” runat=”server”  Text=”Save” CssClass=”buttons” UseSubmitBehavior=”false” />

Posted in asp.net | Tagged: | Leave a Comment »

Download SQL Server 2008 Express with Tools, Including Management Studio

Posted by Sujit Kumar on January 20, 2009

you can download sql server 2008 express with management studio express editions

 link:

http://www.microsoft.com/downloads/details.aspx?FamilyID=7522a683-4cb2-454e-b908-e805e9bd4e28&DisplayLang=en#filelist

Posted in .NET, sql server | Leave a Comment »

Organize “Using” in Visual Studio 2008

Posted by Sujit Kumar on December 31, 2008

organize using

Posted in .NET | Tagged: | Leave a Comment »

Keep the value of Password textboxes after postback

Posted by Sujit Kumar on December 31, 2008

keep the value of password textbox after postback while textbox TextMode properties is “Password”

 

add this line on page_load event

txtPassword.Attributes.Add(“value”,txtPassword.Text);

It will keep text of password textbox while page will go for postback on server.

Posted in asp.net | Tagged: | Leave a Comment »

A potentially dangerous Request.Form value

Posted by Sujit Kumar on November 14, 2008

This error occurs when we try to post html code from code behind.
The reason behind it server always validate the posted data, if it find that its an HTML code, error will occues like ‘A potentially dangerous Request.Form value…’.

if you want to send html data then you hvae to write {validateRequest=”false”} in page directive
ex:

AutoEventWireup=”true” ValidateRequest=”false”

Posted in .NET | Tagged: , | Leave a Comment »

pass multiple query string using HyperLinkField in Gridview

Posted by Sujit Kumar on November 1, 2008

You can pass single/multiple query string using HyperLInkField

Pass data field name in DataNavigateUrlFields which you wnat to pass value in query string
ex:

DataNavigateUrlFields=”subject,query”

here subject and query both are differenct data field those are comming from database.

and write the page name in DataNavigateUrlFormatString where you want to pass query string value.

ex:

DataNavigateUrlFormatString = “~/Pages/default.aspx?UserName={0}&GameTitle={1}”

asp:HyperLinkField HeaderText=”View Details” DataNavigateUrlFields=”subject,query” DataNavigateUrlFormatString = “~/Pages/default.aspx?UserName={0}&GameTitle={1}” Text=”View”

Posted in .NET | Tagged: | 1 Comment »

Show Image from SQL Server in ASP.NET Using C#

Posted by Sujit Kumar on October 3, 2008

Show Image from SQL Server in ASP.NET Using C#

SqlConnection objConnection;
SqlCommand objCommand;
SqlDataAdapter objAdapter;
DataSet objDS=new DataSet();

using (objConnection = new SqlConnection(“server=sujitkumar\\sqlexpress;database=livechat;uid=sa;pwd=1234″))
{
objConnection.Open();
using (objCommand = new SqlCommand())
{
objCommand.Connection = objConnection;

objCommand.CommandType = CommandType.Text;
objCommand.CommandText = “select img_online from image_master”;

objAdapter = new SqlDataAdapter(objCommand);
objAdapter.Fill(objDS, “CustomerAttributes”);
}
objConnection.Close();
}

MemoryStream stream = new MemoryStream();
byte[] image = (byte[])objDS.Tables[0].Rows[0][0];
Response.ContentType = “image/jpeg”;
Response.Expires = 0; Response.Buffer =true;
Response.Clear();
Response.BinaryWrite(image);
Response.End();

The above code will write image on the page.

You can show this image in any image button or image control like:


Posted in asp.net | Tagged: , | Leave a Comment »