create table #Test (
ProdID varchar(5),
ProdDesc varchar(256)
)
insert into #Test (
ProdID,
ProdDesc
)
select 'Prod1', 'Description 1' union all
select 'Prod1', 'Description 2' union all
select 'Prod2', 'Description 1' union all
select 'Prod3', 'Description 1' union all
select 'Prod3', 'Description 2' union all
select 'Prod3', 'Description 3' union all
select 'Prod3', 'Description 4'
select distinct
a.ProdID,
stuff((select
',' + b.ProdDesc
from
#Test b
where
b.ProdID = a.ProdID
for xml path('')),1,1,'') as ProdDesc
from
#Test a
Monday, November 22, 2010
Thursday, October 28, 2010
Autocomplete feature of textbox
write the below code in aspx page inside the javascript tag:
$(document).ready(function(){ $("#<%=fname.ClientID%>").autocomplete("TestHandler.ashx"); });
where fname is your textbox name .
In TestHandler.ashx write the below code:
using System;
using System.Web;
using System.Data;
public class TestHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string Dealercode = context.Request.QueryString["q"];
DataSet objds = new DataSet();
//get the dataset from your class.Here dataprocessor is a class having
//runspreturndataset method which will return the dataset.
objds = DataProcessor.RunSpReturnDataset("get_dealer_details", Dealercode);
string[] items = new string[objds.Tables[0].Rows.Count];
foreach (DataRow dr in objds.Tables[0].Rows)
{
//items.SetValue(dr["dealercode"].ToString(), Convert.ToInt32(dr["tmsw_dealer_id"].ToString()));
context.Response.Write(dr["dealer_code"].ToString().TrimEnd() +"-"+ dr["dealership_name"].ToString().Trim() + Environment.NewLine);
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
$(document).ready(function(){ $("#<%=fname.ClientID%>").autocomplete("TestHandler.ashx"); });
where fname is your textbox name .
In TestHandler.ashx write the below code:
using System;
using System.Web;
using System.Data;
public class TestHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string Dealercode = context.Request.QueryString["q"];
DataSet objds = new DataSet();
//get the dataset from your class.Here dataprocessor is a class having
//runspreturndataset method which will return the dataset.
objds = DataProcessor.RunSpReturnDataset("get_dealer_details", Dealercode);
string[] items = new string[objds.Tables[0].Rows.Count];
foreach (DataRow dr in objds.Tables[0].Rows)
{
//items.SetValue(dr["dealercode"].ToString(), Convert.ToInt32(dr["tmsw_dealer_id"].ToString()));
context.Response.Write(dr["dealer_code"].ToString().TrimEnd() +"-"+ dr["dealership_name"].ToString().Trim() + Environment.NewLine);
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
Sort dropdown in ascending order.
private void SortDDL(ref DropDownList myddl)
{
ArrayList textList = new ArrayList();
ArrayList valueList = new ArrayList();
foreach (ListItem li in myddl.Items)
{
textList.Add(li.Text);
}
textList.Sort();
textList.Reverse();
foreach (object item in textList)
{
string value = myddl.Items.FindByText(item.ToString()).Value;
valueList.Add(value);
}
myddl.Items.Clear();
for (int i = 0; i < textList.Count; i++)
{
ListItem objItem = new ListItem(textList[i].ToString(), valueList[i].ToString());
myddl.Items.Add(objItem);
}
}
{
ArrayList textList = new ArrayList();
ArrayList valueList = new ArrayList();
foreach (ListItem li in myddl.Items)
{
textList.Add(li.Text);
}
textList.Sort();
textList.Reverse();
foreach (object item in textList)
{
string value = myddl.Items.FindByText(item.ToString()).Value;
valueList.Add(value);
}
myddl.Items.Clear();
for (int i = 0; i < textList.Count; i++)
{
ListItem objItem = new ListItem(textList[i].ToString(), valueList[i].ToString());
myddl.Items.Add(objItem);
}
}
Saturday, May 1, 2010
IIS Isolation Levels?
Internet Information Server: IIS5 supports three isolation levels, that you can set from the Home Directory tab of the site Properties dialog:
* Low (IIS Process): ASP pages run in INetInfo.Exe the main IIS process, therefore they are executed in-process. The problem is that if ASP crashes, IIS crashes as well and must be restarted (IIS5 has a reliable restart feature that automatically restarts a server when a fatal error occurs).
* Medium (Pooled): In this case ASP runs in a different process, which makes this setting more reliable and if ASP crashes IIS will not crash. All the ASP applications at the Medium isolation level share the same process, so you can have a web site running with just two processes (IIS and ASP process). IIS5 is the first Internet Information Server version that supports this setting, which is also the default setting when you create an IIS5 application.
* High (Isolated): Each ASP application runs out-process in its own process space, therefore if an ASP application crashes, neither IIS nor any other ASP application will be affected. The downside is that you consume more memory and resources if the server hosts many ASP applications.
When selecting an isolation level for your ASP application keep in mind that out-process settings - that is, Medium and High - are less efficient than in-process (Low). However out-process communication has been vastly improved under IIS5 In practice, you shouldn't set the Low isolation level for an IIS5 application unless you really need to serve hundreds pages per second.
* Low (IIS Process): ASP pages run in INetInfo.Exe the main IIS process, therefore they are executed in-process. The problem is that if ASP crashes, IIS crashes as well and must be restarted (IIS5 has a reliable restart feature that automatically restarts a server when a fatal error occurs).
* Medium (Pooled): In this case ASP runs in a different process, which makes this setting more reliable and if ASP crashes IIS will not crash. All the ASP applications at the Medium isolation level share the same process, so you can have a web site running with just two processes (IIS and ASP process). IIS5 is the first Internet Information Server version that supports this setting, which is also the default setting when you create an IIS5 application.
* High (Isolated): Each ASP application runs out-process in its own process space, therefore if an ASP application crashes, neither IIS nor any other ASP application will be affected. The downside is that you consume more memory and resources if the server hosts many ASP applications.
When selecting an isolation level for your ASP application keep in mind that out-process settings - that is, Medium and High - are less efficient than in-process (Low). However out-process communication has been vastly improved under IIS5 In practice, you shouldn't set the Low isolation level for an IIS5 application unless you really need to serve hundreds pages per second.
How you will handle session when deploying application in more than a server? Describe session handling in a webfarm, how does it work and what are th
By default, ASP.NET will store the session state in the same process that processes the request. ASP.NET can store session data in an external process which can even reside on another machine. To enable this feature:
* Start the ASP.NET state service, either using the Services snap-in or by executing "net start aspnet_state" on the command line. The state service will by default listen on port 42424.
* Set the mode attribute of the section to "StateServer".
* Configure the stateConnectionString attribute with the values of the machine on which you started aspnet_state.
* Start the ASP.NET state service, either using the Services snap-in or by executing "net start aspnet_state" on the command line. The state service will by default listen on port 42424.
* Set the mode attribute of the section to "StateServer".
* Configure the stateConnectionString attribute with the values of the machine on which you started aspnet_state.
How does an AppDomain get created?
AppDomains are usually created by hosts like Windows Shell, ASP.NET and IE etc.
When you run a .NET application from the command-line the host is the Shell. The Shell creates a new AppDomain for every application.
AppDomains can also be explicitly created by .NET applications. Here is a C# sample which creates an AppDomain creates an instance of an object inside it, and then
executes one of the object's methods.
using System;
using System.Runtime.Remoting;
public class AppDomainInfo : MarshalByRefObject
{
public string GetAppDomainInfo()
{
return "AppDomain = " + AppDomain.CurrentDomain.FriendlyName;
}
}
public class App
{
public static int Main()
{
AppDomain ad = AppDomain.CreateDomain( "My new domain", null, null );
ObjectHandle objh = ad.CreateInstance( "appdomaintest", "GetAppDomainInfo");
GetAppDomainInfo myInfo = (GetAppDomainInfo)(objh.Unwrap());
string info = myInfo.GetAppDomainInfo();
Console.WriteLine( "AppDomain : " + info );
return 0;
}
}
When you run a .NET application from the command-line the host is the Shell. The Shell creates a new AppDomain for every application.
AppDomains can also be explicitly created by .NET applications. Here is a C# sample which creates an AppDomain creates an instance of an object inside it, and then
executes one of the object's methods.
using System;
using System.Runtime.Remoting;
public class AppDomainInfo : MarshalByRefObject
{
public string GetAppDomainInfo()
{
return "AppDomain = " + AppDomain.CurrentDomain.FriendlyName;
}
}
public class App
{
public static int Main()
{
AppDomain ad = AppDomain.CreateDomain( "My new domain", null, null );
ObjectHandle objh = ad.CreateInstance( "appdomaintest", "GetAppDomainInfo");
GetAppDomainInfo myInfo = (GetAppDomainInfo)(objh.Unwrap());
string info = myInfo.GetAppDomainInfo();
Console.WriteLine( "AppDomain : " + info );
return 0;
}
}
Subscribe to:
Posts (Atom)