Tag - ASP.NET

Two Databound fields in Gridview column ASP.NET

Boundfields are great in the Gridview, but they do have their limitations.One is that it only has room for one bound field. So, what do you do when you want two or data fields.For example, First and Last names returned to the same column.Turn the BoundField into a TemplateField, with a label in it: <asp:templatefield> ...

Select DropDownList item after declarative DataBinding

The declarative controls of ASP.NET are really great. However, there are some times, when it may not seem so.Let's say you have a DropDownList which is bound by a DataSource control. Also, you have other pages hitting this page, with querystrings, and based on the item in the querystring, you'd like the to select that...

A potentially dangerous Request.Form value was detected from the client ASP.NET

I got this error message when I try to submit a form with HTML Code, the default settings of the .NET Framework will not allow me to submit HTML Code to prevent cross-site scripting (XSS) attacks. To avoid this error set Validate Request to false in the Page Directive.ValidateRequest="false" but this is not recommended.

Visual Studio 2005/2008 on Vista Internet Explorer cannot display the webpage

I faced a strange problem with Visual Studio 2005 and Visual Studio 2008 which is I have several ASP.NET Projects some of them using .NET 2.0 or Visual Studio 2005 and the others are using .NET 3.5 or Visual Studio 2008. The problem was when I try to run the Web Application I got this...

How to Access controls on Master Pages from Content Pages in ASP .NET

We will assume that we have a Label control called "Label1" on your Master Page, you might want to change the text of that Label.To do that write this code in your content page: Label lbl = new Label(); lbl = (Label)Master.FindControl("Label1"); lbl.Text = "Text"; Of course, this is all assuming the label is OUTSIDE the ContentPlaceHolder

Cross Page Postback in ASP.NET

This is a new feature in ASP .NET 2.0. The IButtonControl Interface contains a new property called PostBackUrl which points to the page to which the current page will postback, Button, ImageButton and LinkButton implements this interface and exposes the cross page postback functionality. When user clicks the button in the current page will postback...

Export to excel in ASP.NET using C#

In this article we are going to show two examples of exporting to excel. First one is how to export grid view control to excel and the second one is how to export data table to excel. 1-Export Grid View control to Excel: HtmlForm htmlForm = new HtmlForm(); string fileName = "attachment; filename=Reports.xls"; Response.ClearContent(); Response.AddHeader("content-disposition", fileName); Response.ContentType = "application/ms-excel"; StringWriter strw...