Live Chat Icon For mobile
Live Chat Icon

ASP.NET FAQ

Find answers for the most frequently asked questions
Expand All Collapse All

page1.aspx


<asp:TextBox id='txtSelect' style='Z-INDEX: 101; LEFT: 186px; POSITION: absolute; TOP: 19px'
	runat='server'></asp:TextBox>
<a href='javascript:my_window = window.open(’page2.aspx?formname=Form1.txtSelect’ , ’my_window’,’width=300,height=300’); my_window.focus()'>
	Select CategoryName</a>

page2.aspx


<asp:DropDownList id='DropDownList1' style='Z-INDEX: 101; LEFT: 180px; POSITION: absolute; TOP: 66px'
	runat='server' AutoPostBack='True'>
<asp:Label id='Label1' style='Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 66px' runat='server'>Select Category  Name
<asp:Literal id='Literal1' runat='server'>

VB.NET


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	’Put user code to initialize the page here
	If Not Page.IsPostBack Then
		’Fill DataSet ....	
	            DropDownList1.DataSource = ds.Tables(0)
	            DropDownList1.DataTextField = 'CategoryName'
	            DropDownList1.DataValueField = 'CategoryId'
	            DropDownList1.DataBind()
	End If
End Sub

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
	Try
	            Dim strjscript As String = '<script language=''javascript''>'
	            strjscript = strjscript & 'window.opener.' & HttpContext.Current.Request.QueryString('formname') & '.value = ’' & DropDownList1.SelectedItem.Text & '’;window.close();'
	            strjscript = strjscript & '</script>'
	            Literal1.Text = strjscript
	Catch ex As Exception
	            Response.Write(ex.Message)
	End Try
End Sub

C#


private void Page_Load(object sender, System.EventArgs e)
{
	// Put user code to initialize the page here
	if (!Page.IsPostBack )
	{
	            //Fill DataSet
                            DropDownList1.DataSource = ds.Tables[0];
	            DropDownList1.DataTextField = 'CategoryName';
	            DropDownList1.DataValueField = 'CategoryId';
	            DropDownList1.DataBind();
	}
}

private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
	try
	{
	            string strjscript  = @'<script language=''javascript''>';
	            strjscript = strjscript + 'window.opener.' + HttpContext.Current.Request.QueryString['formname'].ToString () + '.value = ’' + DropDownList1.SelectedItem.Text + '’;window.close();';
	            strjscript = strjscript + '</script>';
	            Literal1.Text = strjscript;
	}
	catch(Exception ex)
	{
	           Response.Write (ex.Message );
	}
}
Permalink

The reason for this error can be

  • The requested file has been renamed.
  • The requested file has been moved to another location and/or deleted.
  • The requested file is temporarily unavailable due to maintenance, upgrades, or other unknown causes.
  • The requested file does not exist.
  • IIS 6.0: The appropriate Web service extension or MIME type is not enabled.

To resolve this refer Common reasons IIS Server returns ‘HTTP 404 – File not found’ error

Permalink
  • The ASP.NET worker process doesn’t have the correct permissions to connect to or write to the SQL Server database. Either enable impersonation for users, or configure the ASP.NET worker process to run under the SYSTEM account.
  • The ASPNET account cannot establish a named pipes connection to the database server. Try using TCP/IP instead of the Named Pipes protocol to connect to the database by adding ‘Network Library =dbmssocn’ in your connection string

For more information refer

Permalink

Server.Transfer preserves the current page context, so that in the target page you can extract values and such. However, it can have side effects; because Server.Transfer doesnt’ go through the browser, the browser doesn’t update its history and if the user clicks Back, they go to the page previous to the source page.

Another way to pass values is to use something like a LinkButton. It posts back to the source page, where you can get the values you need, put them in Session, and then use Response.Redirect to transfer to the target page. (This does bounce off the browser.) In the target page you can read the Session values as required.

Refer to Passing Values Between Web Forms Pages for more information.

Permalink

Microsoft has designed Migration Assistants to help us convert existing pages and applications to ASP.NET. It does not make the conversion process completely automatic, but it will speed up project by automating some of the steps required for migration.

Below are the Code Migration Assistants

  • ASP to ASP.NET Migration Assistant
  • PHP to ASP.NET Migration Assistant
  • JSP to ASP.NET Migration Assistant

Refer Migrating to ASP.Net

Permalink

The wrap functionality occurs for each cell and not for each row of the DataGrid. Therefore, if you disabled the wrap functionality for all of the DataGrid, text wrapping functionality is not disabled for every row or column.

To resolve this make sure that every column of the DataGrid has the ItemStyle Wrap property explicitly set to False as follows:


<ItemStyle Wrap='False'></ItemStyle>

For more details refer

  • Microsoft Knowledge Base Article – 323169
  • Microsoft Knowledge Base Article – 324165
Permalink

This problem occurs because read access to the Internet Information Services (IIS) metabase and the Microsoft Active Directory directory service has been removed for the Everyone group. This access has been removed because of a security modification in Exchange 2000 Server SP3. CDOEX, CDOSYS, and System.Web.Mail must have access to the IIS metabase to access information about the location of the pickup directory path. This behavior occurs when you use the Sendusingpickup method and if this information is not specified in the application code. Because access is restricted, the non-administrative user under whose security context the application is running cannot read this information from the IIS metabase and Active Directory.
For more information refer Read Access to the Everyone Group Is Removed After You Install Exchange 2000 SP3

Permalink

One approach is to use the Microsoft Web Application Stress tool. It allows you to simulate load on a web server and can be used to test performance. The following kb article covers how to use it (including where to download it from).

Permalink

Microsoft has acknowledged this as a Bug
To set the StartUp Type as desired refer following steps

  1. In Control Panel, open Administrative Tools.
  2. Click Services. The Services window appears.
  3. Expand the Name column so that the complete name of each service appears.

    Note A Startup Type column displays the current Startup Type value for each service.

  4. Double-click the ASP.NET State Service service. The ASP.NET State Service Properties window appears.
  5. On the General tab, click one of the following options in the Startup type list:
    • Manual
    • Automatic
    • Disabled
  6. Click Apply, and then click OK to save your settings.

    In the Services window, notice your changes to the Startup Type in the Startup Type column.

Permalink

Microsoft has designed The ASP to ASP.NET Migration Assistant help us convert ASP pages and applications to ASP.NET. It does not make the conversion process completely automatic, but it will speed up project by automating some of the steps required for migration.

The following Code Migration Assistants are discussed in the link below.

  • ASP to ASP.NET Migration Assistant
  • PHP to ASP.NET Migration Assistant
  • JSP to ASP.NET Migration Assistant

Refer Migrating to ASP.Net

Also refer:

Permalink

Below is the javascript code which is used to add and remove div elements dynamically.Here the div tags are added in one base
div tag container.


<script>
	function AddHtmlElement()
	{
		var divElement = document.getElementById(’MYDIV’); 
		var divNumber= document.getElementById(’hiddenValue’); 
		var num = (document.getElementById(’hiddenValue’).value -1)+ 2; 
		divNumber.value = num; 
		var newdiv = document.createElement(’div’); 
		var divIdName = ’MYDIV’+num;
		newdiv.setAttribute(’id’,divIdName); 
		var divLoadedText=’Div ’+num+’ Is Added!’;	
		divElement.appendChild(newdiv);
		newdiv.innerHTML =divLoadedText+' '+'<a href=’#’ onclick=RemoveHtmlElement(’'+divIdName+'’)>Remove div ’'+divIdName+'’</a>';  
	}
	functionRemoveHtmlElement(divNum)
	{ 
		var divId = document.getElementById(’MYDIV’); 
		var childId = document.getElementById(divNum); 
		divId.removeChild(childId); 
	}
</script>

<form id='Form1' >
	<input id='hiddenValue' type='hidden' value='0'>
	<p>
		<a href='#' onclick='AddHtmlElement()'>Add Html Elements</a>
	</p>
	<div id='MYDIV'></div>
</form>
Permalink

Depends on which mode you are using:

  • InProc Mode- objects stored in session state are actually live objects, and so you can store whatever object you have created.
  • State Server or SQL Server mode, objects in the session state will be serialized and deserialized when a request is processed. So make sure your objects are serializable and their classes must be marked as so. If not, the session state will not be saved successfully. In v1, there is a bug which makes the problem happen unnoticed in SQLServer mode and will make your request hang. The hanging problem is fixed in v1.1. The fix for KB 324479: ASP.NET SQL Server Session State Impersonation Is Lost Under Load also contains the fix for this problem. The problem will be fixed in v1 SP3 too.

    For more info: BUG: Session Data Is Not Saved in Out-of-Process Session State

Permalink

This problem may occur after you install Windows Sharepoint Server(WSS) on a server that has Microsoft Visual Studio .NET 2003 installed. The WSS ISAPI filter handles all incoming URLs. When you browse one of the ASP.NET Web application virtual directories, the ISAPI filter does not locate the URL path of the folder.
To resolve this refer Session state cannot be used in ASP.NET with Windows SharePoint Services

Permalink

The dropDownList has a bug which prevent us from assigning the style property to each item in the DropDownList.
This bug confirmed by Microsoft in Microsoft Knowledge Base Article – 309338
For the workaround use a HTML dropdownlist with runat=server tag


<SELECT id='DropDownList1' runat='server' >
</SELECT>

Use namespace System.Reflection
VB.NET


If Not Page.IsPostBack Then
Dim col As FieldInfo
For Each col In GetType(KnownColor).GetFields
	If col.FieldType Is GetType(Drawing.KnownColor) Then
		DropDownList1.Items.Add(New ListItem(col.Name, col.Name))
	End If
Next
End If

Dim i As Integer
For i = 0 To DropDownList1.Items.Count - 1
	DropDownList1.Items(i).Attributes.Add('style', 'background-color:' + DropDownList1.Items(i).Text)
Next

C#


if (!IsPostBack)
{
	foreach(FieldInfo col in typeof(KnownColor).GetFields() )
	{
		if (col.FieldType == typeof(KnownColor) )
		{
		DropDownList1.Items.Add(new ListItem(col.Name ,col.Name));
		}
	}  
}
for (int i= 0 ;i < DropDownList1.Items.Count;i++)
{
	DropDownList1.Items[i].Attributes.Add('style', 'background-color:' + DropDownList1.Items[i].Text);
}
Permalink

The reason why the encrypted data couldn’t be decrypted on another machine is because the validation key in the original machine’s machine.config is set to AutoGenerate. This means that the generated keys are unique to each machine. A better solution will be to specify the validation key, so you can decrypt it across any machine with the same validation key.
For more details on solution refer following article :

Permalink

For security reasons, you can’t force a user to run any executable.

Instead give user the option to click on it and download the executable, and execute it if he wants to. All you can do is put .exe in a directory on your web site and put a hyperlink to it on some page.

Note : Be sure to secure this directory by deactivating all execution permissions both in the IIS console and in the directory ACL

For more details refer INFO: Executing Files by Hyperlink and the File Download Dialog Box

Permalink

The below example is a demonstration of a simple server control which creates a Text Box.

Follow the below steps to create a new server control.

  1. Open VS.NET 2005.
  2. In File->New Select the Project submenu.
  3. In the Dialog window ,Select the Window, and select the WebControlLibrary.
  4. Select an appropriate path and give a name as TextControl, to create a new server control.
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Text;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;

namespace WebCustomControl1
{
	[DefaultProperty('Text')]
	[ToolboxData('<{0}:WebCustomControl1 runat=server></{0}:WebCustomControl1>')]
	public class WebCustomControl1 : WebControl
	{
		public TextBox _text = new TextBox();
		[Bindable(true)]
		[Category('Appearance')]
		[DefaultValue('')]
		[Localizable(true)]
		
		public string Text
		{
			get
			{
				String s = (String)ViewState['Text'];
				return ((s == null) ? String.Empty : s);
			}
			set
			{
				ViewState['Text'] = value;
			}
		}
	
		protected override void CreateChildControls()
		{
			 _text.Width = 200;
			 _text.Height = 50;
			 _text.Text = 'Server Control Creation';
			this.Controls.Add(_text);
		}

		protected override void RenderContents(HtmlTextWriter writer)
		{
			this.EnsureChildControls();
			this.RenderChildren(writer);            
		}
	}
}

Here is an article from ftp online: Build an ASP.NET Server Control that explains how to build a ‘Login Control’.

Permalink

Two techniques for exporting the data in the DataGrid:

  • Using the Excel MIME Type (or Content Type)

    With server-side code, you can bind the DataGrid to your data and have the data open in Excel on a client computer. To do this, set the ContentType to application/vnd.ms-excel. After the client receives the new stream, the data appears in Excel as if the content was opened as a new page in the Web browser.

  • Using Excel Automation
    With client-side code, you can extract the HTML from the DataGrid and then Automate Excel to display the HTML in a new workbook. With Excel Automation, the data always appears outside the browser in an Excel application window. One advantage to Automation is that you can programmatically control Excel if you want to modify the workbook after the data is exported. However, because Excel is not marked as safe for scripting, your clients must apply security settings in the Web browser that allow Automation.

For more details refer How To Export Data in a DataGrid on an ASP . NET WebForm to Microsoft Excel

Permalink

The ListBox Web server control prevents us from assigning the style property to each item in the ListBox. This bug is confirmed by Microsoft Knowledge Base Article – 309338

So, instead use a HTML ListBox with runat=server


<SELECT id='listbox1' size='14' runat='server' >
</SELECT>

VB.NET


Dim myconnection As SqlConnection
Dim myda As SqlDataAdapter
Dim ds As DataSet
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	myconnection = New SqlConnection('Server=localhost;uid=sa;password=;database=northwind;')
	myda = New SqlDataAdapter('Select * from Products ', myconnection)
	ds = New DataSet()
	myda.Fill(ds, 'AllTables')
	dim i as Integer
	For i = 0 To ds.Tables(0).Rows.Count - 1
		listBox1.Items.Add(New ListItem(ds.Tables(0).Rows(i)('UnitPrice'), ds.Tables(0).Rows(i)('ProductID')))
		If ds.Tables(0).Rows(i)('UnitPrice') <= 25 Then
			listBox1.Items(i).Attributes.Add('style', 'color:red')
		Else
			listBox1.Items(i).Attributes.Add('style', 'color:green')
		End If
	Next
End Sub

C#


SqlConnection mycn;
SqlDataAdapter myda;
DataSet ds;
String strConn;
private void Page_Load(object sender, System.EventArgs e)
{
	if (!IsPostBack)
	{
		strConn='Data Source=localhost;uid=sa;pwd=;Initial Catalog=northwind';
		mycn = new SqlConnection(strConn);
		myda = new SqlDataAdapter ('Select * FROM Products ', mycn);
		ds = new DataSet();
		myda.Fill (ds,'Table');
				
		for(int i = 0 ;i < ds.Tables[0].Rows.Count - 1;i++)
		{
			listBox1.Items.Add (new ListItem(ds.Tables[0].Rows[i]['UnitPrice'].ToString(),
			ds.Tables[0].Rows[i]['ProductID'].ToString()));
			if(Convert.ToDouble(ds.Tables[0].Rows[i]['UnitPrice'].ToString()) <= 25 )
			{
				listBox1.Items[i].Attributes.Add('style', 'color:red');
			}
			else
			{
				listBox1.Items[i].Attributes.Add('style', 'color:green');
			}
		}
	}
}
Permalink

To resolve this issue, identify the user account that is used to run the program, and then assign the ‘Impersonate a client after authentication’ user right to that user account. To do this, follow these steps:

  1. Click Start, point to Programs, point to Administrative Tools, and then click Local Security Policy.
  2. Expand Local Policies, and then click User Rights Assignment.
  3. In the right pane, double-click Impersonate a client after authentication.
  4. In the Local Security Policy Setting dialog box, click Add.
  5. In the Select Users or Group dialog box, click the user account that you want to add, click Add, and then click OK.
  6. Click OK.

For more details refer Overview of the ‘Impersonate a Client After Authentication’….

Permalink
  1. The ASPNET worker process doesn’t have ‘Read & Execute’, ‘ List Folder Contents’, ‘ Read permissions’ permissions to detect file changes in Web.Config, Machine.config, Bin files, or Cache dependency files.
  2. Or one of the directory names in the hierarchy of that file path is greater than eight characters long.

For more information refer

Permalink

This problem occurs because the C# compiler does not have permission to access the folders in the path to the mscorlib.dll assembly

To resolve this problem, modify the compiler definition for the C# compiler to include the /nostdlib option. The /nostdlib option prevents the import of the mscorlib.dll assembly, which defines the entire System namespace.
To include the /nostdlib option in the C# compiler definition on a computer, follow these steps:

  1. Open the Machine.config file, and then locate the section.
  2. In the definition for C#, add the compilerOptions attribute with a value of /nostdlib.
    For example:

    
    <compiler language='c#;cs;csharp'
             extension='.cs'
             type='Microsoft.CSharp.CSharpCodeProvider, System,
             Version=1.0.3300.0,
             Culture=neutral,
             PublicKeyToken=b77a5c561934e089'
             warningLevel='1'
             compilerOptions='/nostdlib' />
    

    For more details refer PRB: ‘Compiler Error Message: CS1595’ Error Message When You Use the C# Compiler to Compile an ASP.NET Resource

Permalink

You receive this error message if the following conditions are true:

  • The assembly that is specified in the error message is a signed assembly and is not installed in the Global Assembly Cache (GAC); instead, the assembly is in the Bin directory of the ASP.NET Web application. -and-
  • Your ASP.NET Web application has just been restarted.

For more details refer PRB: ‘Can not Access File ’AssemblyName’ Because It Is Being Used by Another Process’ Error Message in ASP.NET

Permalink

This problem might occur because ASP.NET limits the number of worker threads and completion port threads that a call can use to execute requests.
For more details refer PRB: Contention, poor performance, and deadlocks when you make Web service requests from ASP.NET applications

You could control the deadlock detection by changing machine.config setting in


<processModel responseDeadlockInterval='...'  ... />
Permalink

This problem occurs because of some antivirus applications write back information to the files that they scan. Every time a user changes the Web.config configuration file, the Global.asax file, or the contents of the Bin folder, the application should restart to incorporate these changes. Because antivirus scanning changes cannot be distinguished from the user’s file changes, the application restarts when the antivirus software scans these folders.

Note This problem may occur even when no error is returned. If the virus-scanning software triggers change notifications, every change notification is doubled at the very least: one real change notification and an additional change notification from the antivirus software some time later.
For more information refer PRB: Random application restarts with ‘Application is restarting’ error in ASP.NET

Permalink

When you install the .NET Framework 1.1, a hidden local user account that is named ASPNET is created. When you start Windows, Windows treats the ASPNET local user account as an additional user account, although the ASPNET user account is hidden. Therefore, the Welcome screen appears and prompts you to click your user name.

For more details refer KB 827072

Permalink

The ASPNET worker process doesn’t have the correct permissions to connect to or write to the Access database.

Either enable impersonation for users or configure the ASP.NET worker process to run under the SYSTEM account. You can also grant read and write permissions for the ‘Everyone’ group on the database and the database folder.

For more details refer

Permalink

If someone has run a lockdown or other security tool on the Web server, the
DEBUG method may have been removed.

Go into IIS manager to the Web application’s properties and Directory >Configuration (button) > Mappings > Application mappings.
Check that for .aspx extensions, you allow GET,HEAD,POST,DEBUG

Of course you need to be a member of the Debuggers group on the remote server.
To resolve error

  1. Right-click the Project Name in Solution Explorer, and then click Properties.
  2. In the left pane of Properties, click to select Configuration Properties.
  3. Click to select Debugging.
  4. In the right pane, change the value of Enable Unmanged Debugging to True (on the drop-down list).

For more details refer PRB: Error Message: Unable to Start Debugging. Unable to Start Program …

Permalink

Your ASP.NET project is not setup for debugging.

  • Open up the project’s properties window and set the “Enable ASP.NET Debugging” option.
  • Open up your web.config file and make sure the Compilation tag’s debug attribute is set to true.
<compilation defaultLanguage="vb" debug="true" />

Make sure the account you are logged in as and the ASP.NET Worker process is in the local “Debugger Users” group.

Permalink

This issue occurs if the account that is used to run the ASP.NET Worker process (by default, the ASPNET user account) is not assigned the ‘Impersonate a client after authentication’ user right in the ‘Local Security Policy’ settings. This issue may occur when you install Microsoft Visual
Studio .NET after you install Windows 2000 Service Pack 4 (SP4) on the computer. In this situation, the ASPNET account is not assigned the ‘Impersonate a client after authentication’ user right in the ‘Local Security Policy’ settings.To resolve it, please use the method at:

To work around the problem, manually assign Impersonate a client after authentication to the IWAM account. To do so, follow these steps:

  1. Click Start, point to Programs, point to Administrative Tools, and then click Domain Controller Security Policy.
  2. Click Security Settings.
  3. Click Local Policies, and then click User Rights Assignment.
  4. In the right pane, double-click Impersonate a client after authentication.
  5. In the Security Policy Setting window, click Define these policy settings.
  6. Click Add, and then click Browse.
  7. In the Select Users or Groups window, select the IWAM account name, click Add, and then click OK.
  8. Click OK, and then click OK again.
  9. To enforce an update of computer policy, type the following command:
    secedit /refreshpolicy machine_policy /enforce
  10. At a command prompt, type iisreset.In case your server is a Domain Controller
    Refer PRB: ‘Catastrophic Failure’ Error Message When You Try to Debug an ASP.NET Application on Windows 2000 Domain Controller
Permalink

Your ISP must first create an IIS application and apply the Front Page Server Extensions to it. Then in Visual Studio .NET, select the ‘Project | Copy Project’ menu. Then enter the URL and select the FrontPage web access method. The ‘Copy Project’ feature copies all of the necessary files to your ISP’s machine for your ASP.NET application to run.

You can also FTP your files to your ISP web server. But you must know which files to upload.
For more details refer PRB: Remote ASP.NET Projects Require IIS on the Client Computer or FrontPage Server Extensions on the Server Computer

Permalink

<script language='javascript'>
function SetFocus()
{
	// W3C approved DOM code that will work in all modern browsers	
	if (document.getElementById)
          		document.getElementById(’txt2’).focus();
     	else
     	// To support older versions of IE:
         	if (document.all)
            		document.all('txt2').focus();
    	return false;
}
</script>

<body MS_POSITIONING='GridLayout' onload='SetFocus()'>
<form id='Form1' method='post' runat='server'>
	Enter 1:
	<asp:TextBox ID='txt1' Runat='server' Width='50' />
	<br>
	Enter 2:
	<asp:TextBox ID='txt2' Runat='server' Width='50' />
	<br>
	<asp:Button id='Button1' runat='server' Text='Button1'></asp:Button>
</form>
</body>

Refer
Sample IE Code

Permalink

This happens for example, when you try to export data to excel from a datagrid.

The problem occurs if the server is using Secure Sockets Layer (SSL) and has added one or both of the following HTTP headers to the response message:


Pragma: no-cache
Cache-control: no-cache,max-age=0,must-revalidate

For more details refer PRB: Internet Explorer Is Unable to Open Office Documents from an SSL Web Site

Permalink

Here is an excerpt from the KB article: KB 816782

Find the ASP.NET Version Used for the Application
View the script map for an ASP.NET application to determine the version of ASP.NET that the application uses. To view the script map for an ASP.NET application, follow these steps:

  1. Click Start, point to Programs, and then click Control Panel.
  2. Double-click Administrative Tools, and then double-click Internet Information Services (IIS).
  3. Expand local computer, expand Web Site, and then expand Default Web Site.
  4. Locate the folder that contains the ASP.NET application.
  5. Right-click the folder that contains the ASP.NET application, and then click Properties.
  6. Click the Directory tab, and then click Configuration. The Application Configuration dialog box opens.
  7. Click the Mappings tab, and then select an ASP.NET application extension, such as .asmx or .aspx.
    The Executable Path column of the dialog box lists the path to the ASP.NET ISAPI version that the application uses. By default, the ASP.NET ISAPI is installed in %WindowsDirectory%\Microsoft.NET\Framework\%versionNumber%. The version number in the path indicates the version number of the ASP.NET ISAPI that the application uses. The ASP.NET ISAPI version determines the version of the runtime that the application uses.

Use Aspnet_regiis.exe to Update the Script Map
To make it easier to reconfigure the script map for an ASP.NET application, each installation of the .NET Framework is associated with a version of the ASP.NET IIS Registration tool (Aspnet_regiis.exe). You can use this tool to remap an ASP.NET application to the ASP.NET ISAPI version associated with the tool.

Note Because Aspnet_regiis.exe is linked to a specific version of the .NET Framework, you must use the appropriate version of Aspnet_regiis.exe to reconfigure the script map for an ASP.NET application. Aspnet_regiis.exe only reconfigures the script map of an ASP.NET application to the ASP.NET ISAPI version associated with the tool

Configure ASP.NET 1.0 for the Application
When ASP.NET 1.1 is configured on the root Web site, follow these steps to configure ASP.NET 1.0 for an application:

  1. Click Start, and then click Run. In the Open text box, type cmd, and then click OK.
  2. At the command prompt, locate the following directory path:
    %WindowsDirectory%\Microsoft.NET\Framework\v1.0.3705\
  3. Type the following command to configure the ASP.NET 1.0 application in IIS:
    
    aspnet_regiis -s w3svc/1/root/ApplicationName 
    

    To remove ASP.NET 1.0 from this application, repeat steps 1and 2, and then type the following command:

    
    aspnet_regiis -k w3svc/1/root/ApplicationName
    

Configure ASP.NET 1.1 for the Application
When ASP.NET 1.0 is configured on the root Web site, follow these steps to configure ASP.NET 1.1 to run an application:

  1. Click Start, and then click Run. In the Open text box, type cmd, and then click OK.
  2. At the command prompt, locate the following directory path:
    %WindowsDirectory%\Microsoft.NET\Framework\v1.1.4322
  3. If ASP.NET 1.1 is not already registered, type the following command to register it:
    aspnet_regiis -ir
    Note The -ir option registers ASP.NET 1.1 without updating the scripts in IIS.
  4. Type the following to configure the ASP.NET 1.1 application in IIS:
    
    aspnet_regiis -s w3svc/1/root/ApplicationName 
    

    To remove ASP.NET 1.1 from this application, repeat steps 1 and 2, and then type the following command:

    
    aspnet_regiis -k w3svc/1/root/ApplicationName
    
Permalink

By default, ASP.NET runs its worker process (Aspnet_wp.exe) with a weak account (the local machine account, which is named ASPNET) to provide a more secure environment. On a domain controller or on a backup domain controller, all user accounts are domain accounts and are not local machine accounts. Therefore, Aspnet_wp.exe fails to start because it cannot find a local account named ‘localmachinename\ASPNET’. To provide a valid user account on the domain controller, you must specify an explicit account in the section of the Machine.config file, or you must use the SYSTEM account.
For more details : FIX: ASP.NET Does Not Work with the Default ASPNET Account on a Domain Controller
Permalink

This is because if you have the /3GB boot switch enabled, the ASP.NET worker process (Aspnet_wp.exe) does not start. For more information see Microsoft Knowledge Base Article – 320353

To create and set the ‘ASPNETENABLE3GB’ environment variable as mentioned in the above article, right click MyComputer ->Properties->Advanced > Environment Variables > System variables > New.

Add the variable name in the top text box and the value in the lower textbox.

Permalink

Refer : How to add Templatecolumn dynamically to DataList?

Now, instead of DataList use Repeater and make below changes

VB.NET


Public Sub BindLabelColumn(sender As Object, e As EventArgs)
   	Dim lbl As Label = CType(sender, Label)
   	Dim container As RepeaterItem = CType(lbl.NamingContainer, RepeaterItem)
   	Dim strVals As String = Convert.ToString(DataBinder.Eval(CType(container, RepeaterItem).DataItem, 'LastName')) + ', ' + Convert.ToString(DataBinder.Eval(CType(container, RepeaterItem).DataItem, 'FirstName'))
	lbl.Text = strVals
End Sub ’BindLabelColumn 

C#


public void BindLabelColumn(object sender, EventArgs e)
{     
       	 Label lbl = (Label)sender;
	RepeaterItem   container = (RepeaterItem)lbl.NamingContainer ;
	String strVals =Convert.ToString(DataBinder.Eval(((RepeaterItem)container).DataItem, 'LastName')) 
		+ ', ' +
	Convert.ToString(DataBinder.Eval(((RepeaterItem)container).DataItem, 'FirstName')) ;
	lbl.Text  = strVals;
		
}
Permalink

<asp:Calendar id='Calendar1' OnDayRender ='CalDayRender' runat='server'></asp:Calendar>

Dim ds As DataSet
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	’Put user code to initialize the page here
	’Fill the DataSet 
End Sub

Protected Sub CalDayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)
	Dim strName As New StringBuilder
	strName.Append('
')
	Dim theDay As DateTime = e.Day.Date
	Dim sql As String = 'hiredate=’' + DateTime.Parse(theDay.ToString('d')) + '’ '
	Dim dr As DataRow() = ds.Tables(0).Select(sql)
	Dim drRow As DataRow
	For Each drRow In dr
	            strName.Append('’<a href=empdetails.aspx?id=' + drRow('Employeeid').ToString() + '>' + drRow('FirstName').ToString() + ' ' + drRow('LastName').ToString() + '</a><br>’')
	            e.Cell.BackColor = Color.Teal
	            e.Cell.ForeColor = Color.Wheat
        	Next drRow
	strName.Append('')
	e.Cell.Controls.Add(New LiteralControl(strName.ToString()))
End Sub ’CalDayRender

C#


DataSet ds  ;
private void Page_Load(object sender, System.EventArgs e)
{
	// Put user code to initialize the page here
	//Populate the DataSet
}

protected void CalDayRender(object sender, DayRenderEventArgs e)
{
	StringBuilder strName = new StringBuilder();
	strName.Append('
');
	DateTime theDay = e.Day.Date;
	string sql ='hiredate=’' + DateTime.Parse ( theDay.ToString('d')) + '’ ';
	DataRow [] dr = ds.Tables[0].Select(sql);
	foreach(DataRow drRow in dr)
	{
		strName.Append('’<a href=empdetails.aspx?id=' + drRow('Employeeid').ToString() + '>' + drRow('FirstName').ToString() + ' ' + drRow('LastName').ToString() + '</a><br>’')
		e.Cell.BackColor = Color.Teal;
		e.Cell.ForeColor = Color.Wheat;
	}
	strName.Append('');
	e.Cell.Controls.Add(new LiteralControl(strName.ToString()));
} 
Permalink

Some common mistakes that will cause the designer to choke while persisting collection properties are:

  • The corresponding collection type cannot have multiple (overloaded) indexers. You should always define a single indexer of the type ‘public SomeType this[object obj]{…}‘. Otherwise the changes will be persisted but the control will not load in the designer. You will see a ‘Ambiguous match found’ error.
  • If the collection property has the PersistenceMode attribute set to InnerProperty then the property should not include a set method.
  • Permalink

    A MultiView is a non-visual control that provides a pallette where a several view Controls can be placed. A view control is another non-visual control where you can place the user interface controls.It is simillar to that of a Tab control.The below code demonstrate how MultiView can be created,

    
    <div>
    	<asp:Button id='Button1' runat='server' Text='View 1' OnClick='Button1_Click' />
    	<asp:Button id='Button2' runat='server' Text='View 2' OnClick='Button2_Click' /> 
    	<asp:Button id='Button3' runat='server' Text='View 3' OnClick='Button3_Click' />
    	<br />
    	<br />
    	<asp:MultiView id='MultiView1' runat='server' ActiveViewIndex=0>
    		<asp:View id='View1' runat='server'>
    			Content Here (View 1)...
    		 	<asp:BulletedList  ID='BulletedList1' runat='server'>
    				<asp:ListItem>My Schedule On 1st Week</asp:ListItem>
    				<asp:ListItem>My Schedule On 2nd Week</asp:ListItem>
    				<asp:ListItem>My Schedule On 3rd Week</asp:ListItem>
    				<asp:ListItem>My Schedule On 4th Week</asp:ListItem>
    			</asp:BulletedList>
    		</asp:View>
    		<asp:View id='View2' runat='server'>
    			Content Here (View 2)...
    			<asp:Calendar ID='Calendar1' runat='server' BackColor='#FFFFCC' 
    				BorderColor='#FFCC66' BorderWidth='1px' DayNameFormat='Shortest' 
    				Font-Names='Verdana' Font-Size='8pt' ForeColor='#663399' Height='200px'
    				 ShowGridLines='True' Width='220px'>
    				<SelectedDayStyle BackColor='#CCCCFF' Font-Bold='True' />
    				<TodayDayStyle BackColor='#FFCC66' ForeColor='White' />
    				<SelectorStyle BackColor='#FFCC66' />
    				<OtherMonthDayStyle ForeColor='#CC9966' />
    				<NextPrevStyle Font-Size='9pt' ForeColor='#FFFFCC' />
    				<DayHeaderStyle BackColor='#FFCC66' Font-Bold='True' Height='1px' />
    				<TitleStyle BackColor='#990000' Font-Bold='True' Font-Size='9pt' 
    				ForeColor='#FFFFCC' />
    			</asp:Calendar>
    		</asp:View>
    		<asp:View id='View3' runat='server'>
    			Content Here (View  3)...
    			<br />
    			<asp:Label ID='Label1' runat='server' Text='Schedule Details'></asp:Label>
    		</asp:View>
    	</asp:MultiView>
    </div>
    
    Permalink

    Validation Groups allows the different section of the webpage to be validated seperately. All the ASP.NET 2.0 Validation controls,interactive form controls like TextBox,list controls Button and other controls that are used to submit a webform have validationGroup property. The default value of this property is the empty string. When a button with a ValidationGroup property is clicked all of the validation controls on the page with the same ValidationGroup property value are executed.

    On postback, the Page.IsValid property checks the validity of all of the validation controls. Programmatically it can be checked by the Validate() Method.

    
    <html>
    	<head runat='server'>
    		<title>Validation Groups</title>
    		<script runat='server'>
    			void Group1Click(Object s, EventArgs e)
    			{
    				if (Page.IsValid)
    				{
                             		                	lblResult.Text = 'Name Validated & Submitted';
    				}
    			}
    
    			void Group2Click(Object s, EventArgs e)
    			{
    				if (Page.IsValid)
    				{
    					lblResult.Text = 'Age Validated & Submitted';
    				}
    			}
    		</script>
    
    	</head>
    	<body>
    		<form id='form1' runat='server'>
    			<div>
    				<asp:Label ID='lblResult' Runat='Server' />
        				<fieldset style='padding:20px'>
    					<legend>Name</legend>
    					<asp:Label ID='Name' runat='server' Text='Name:'></asp:Label>
    	       				<asp:TextBox id='TextBox1' Runat='Server'/>
    					<asp:Button ID='Button1' ValidationGroup='Group1' Text='Submit' 
    						OnClick='Group1Click'  Runat='Server' />
    					<asp:RequiredFieldValidator ID='RequiredFieldValidator1' 
    						ValidationGroup='Group1'  ControlToValidate='TextBox1'
    					       	Text='Field Cannot Be Empty' Runat='Server' />
    				</fieldset>
            
        				<fieldset style='padding:20px'>
    					<legend>Age</legend>
    					<asp:Label ID='Label1' runat='server' Text='Age:'></asp:Label>
            
        					<asp:TextBox  id='TextBox2' Runat='Server' />
    					<asp:Button ID='Button2'   ValidationGroup='Group2' Text='Submit'
    						  OnClick='Group2Click'  Runat='Server' />
    					<asp:RangeValidator ID='RangeValidator1' runat='server' ErrorMessage='Enter Age 
    						   between 18 To 58'  MaximumValue='58' MinimumValue='18' 
    						   ValidationGroup='Group2' ControlToValidate='TextBox2'>
    					            Enter Age between 18 To 58</asp:RangeValidator>
    				</fieldset>
            			</div>
        		</form>
    	</body>
    </html>
    
    Permalink

    A master page is a template that you can use to define the overall look and feel of your ASP.NET Web applications. In previous versions of ASP.NET, you were forced to embed user controls in every page to get consistency. Master pages now make it much easier to deliver a consistent look and feel, without the need to embed user controls across all of your pages.

    Here is an article from ftp online: Create Master Pages in ASP.NET 2.0.

    Permalink

    Share with

    Share on twitter
    Share on facebook
    Share on linkedin

    Couldn't find the FAQs you're looking for?

    Please submit your question and answer.