1. file attribute will take both inline keys of web.config + keys of external file
2. configSource attribute - we have to move entire section to external file
Thursday, May 31, 2007
javascript alert from UpdatePanel
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Record Successfully Saved')", true);
The last true is to add javascript tags
The last true is to add javascript tags
javascript alert from ASP.NET codebehind
string scriptString = "LT..script language="JavaScript"..GT javascript:alert('Record Saved');window.opener.location.reload();window.close();";
scriptString += "LT";
scriptString += "/";
scriptString += "script..GT";
if (!ClientScript.IsClientScriptBlockRegistered("clientScript"))
ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", scriptString);
scriptString += "LT";
scriptString += "/";
scriptString += "script..GT";
if (!ClientScript.IsClientScriptBlockRegistered("clientScript"))
ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", scriptString);
UpdateProgress Panel is always in new line
UpdateProgress Panel is always placed in a new line. To avoid the page flips when updateprogress is called -- use it in a new td tag inside table html
DataSet.Merge or DataSet.Relations
1. For rows - columns merge - use DataSet.Merge
2. For Master-Detail (Primary key - foreign key) table relations - use DataSet.Relations
3. If you want to join two datatables based on some condition and display columns from both the tables, you have to manually find the key value by "for" loop and then create a new dataset..
For example if you take employee table from sql database and department from oracle database and you want to display empno, empname, deptid, deptname in one single table...manual binding is easier way.
2. For Master-Detail (Primary key - foreign key) table relations - use DataSet.Relations
3. If you want to join two datatables based on some condition and display columns from both the tables, you have to manually find the key value by "for" loop and then create a new dataset..
For example if you take employee table from sql database and department from oracle database and you want to display empno, empname, deptid, deptname in one single table...manual binding is easier way.
SoapException for Webservices
public class Common
{
public enum FaultCode
{
Client=0, Server=1
}
#region Soap Exception
///
/// To raise Soap Exception
public static SoapException RaiseException(string uri, string webServiceNamespace, string errorMessage, string errorNumber, string errorSource, FaultCode code)
{
XmlQualifiedName faultCodeLocation = null;
//Identify the location of the FaultCode
switch (code)
{
case FaultCode.Client:
faultCodeLocation = SoapException.ClientFaultCode;
break;
case FaultCode.Server:
faultCodeLocation = SoapException.ServerFaultCode;
break;
}
XmlDocument xmlDoc = new XmlDocument();
//Create the Detail node
XmlNode rootNode = xmlDoc.CreateNode(XmlNodeType.Element,
SoapException.DetailElementName.Name,
SoapException.DetailElementName.Namespace);
//Build specific details for the SoapException
//Add first child of detail XML element.
XmlNode errorNode = xmlDoc.CreateNode(XmlNodeType.Element, "Error",
webServiceNamespace);
//Create and set the value for the ErrorNumber node
XmlNode errorNumberNode =
xmlDoc.CreateNode(XmlNodeType.Element, "ErrorNumber",
webServiceNamespace);
errorNumberNode.InnerText = errorNumber;
//Create and set the value for the ErrorMessage node
XmlNode errorMessageNode = xmlDoc.CreateNode(XmlNodeType.Element,
"ErrorMessage",
webServiceNamespace);
errorMessageNode.InnerText = errorMessage;
//Create and set the value for the ErrorSource node
XmlNode errorSourceNode =
xmlDoc.CreateNode(XmlNodeType.Element, "ErrorSource",
webServiceNamespace);
errorSourceNode.InnerText = errorSource;
//Append the Error child element nodes to the root detail node.
errorNode.AppendChild(errorNumberNode);
errorNode.AppendChild(errorMessageNode);
errorNode.AppendChild(errorSourceNode);
//Append the Detail node to the root node
rootNode.AppendChild(errorNode);
//Construct the exception
SoapException soapEx = new SoapException(errorMessage,
faultCodeLocation, uri,
rootNode);
//Raise the exception back to the caller
return soapEx;
}
#endregion
}
{
public enum FaultCode
{
Client=0, Server=1
}
#region Soap Exception
///
/// To raise Soap Exception
public static SoapException RaiseException(string uri, string webServiceNamespace, string errorMessage, string errorNumber, string errorSource, FaultCode code)
{
XmlQualifiedName faultCodeLocation = null;
//Identify the location of the FaultCode
switch (code)
{
case FaultCode.Client:
faultCodeLocation = SoapException.ClientFaultCode;
break;
case FaultCode.Server:
faultCodeLocation = SoapException.ServerFaultCode;
break;
}
XmlDocument xmlDoc = new XmlDocument();
//Create the Detail node
XmlNode rootNode = xmlDoc.CreateNode(XmlNodeType.Element,
SoapException.DetailElementName.Name,
SoapException.DetailElementName.Namespace);
//Build specific details for the SoapException
//Add first child of detail XML element.
XmlNode errorNode = xmlDoc.CreateNode(XmlNodeType.Element, "Error",
webServiceNamespace);
//Create and set the value for the ErrorNumber node
XmlNode errorNumberNode =
xmlDoc.CreateNode(XmlNodeType.Element, "ErrorNumber",
webServiceNamespace);
errorNumberNode.InnerText = errorNumber;
//Create and set the value for the ErrorMessage node
XmlNode errorMessageNode = xmlDoc.CreateNode(XmlNodeType.Element,
"ErrorMessage",
webServiceNamespace);
errorMessageNode.InnerText = errorMessage;
//Create and set the value for the ErrorSource node
XmlNode errorSourceNode =
xmlDoc.CreateNode(XmlNodeType.Element, "ErrorSource",
webServiceNamespace);
errorSourceNode.InnerText = errorSource;
//Append the Error child element nodes to the root detail node.
errorNode.AppendChild(errorNumberNode);
errorNode.AppendChild(errorMessageNode);
errorNode.AppendChild(errorSourceNode);
//Append the Detail node to the root node
rootNode.AppendChild(errorNode);
//Construct the exception
SoapException soapEx = new SoapException(errorMessage,
faultCodeLocation, uri,
rootNode);
//Raise the exception back to the caller
return soapEx;
}
#endregion
}
Crystal Report & Crystal Enterprise
Crystal Report
---------------
private void BindReport()
{
this.crReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
crReportDocument.Load(Server.MapPath("users.rpt"));
DataSet ds = new DataSet();
ds = ListUsers(0, 0);
crReportDocument.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = crReportDocument;
CrystalReportViewer1.DataBind();
}
------------------------------------------------------------------------------------------------
Crystal Enterprise
private void BindReport()
{
crReportDocument.EnterpriseLogonInfo.CmsServer = "..";
crReportDocument.EnterpriseLogonInfo.Password = "..";
crReportDocument.EnterpriseLogonInfo.Username = "..";
crReportDocument.FileName = "..";
crReportDocument.UriIsUserEditable = false;
CrystalReportViewer1.ReportSource = crReportDocument;
CrystalReportViewer1.DataBind();
}
---------------
private void BindReport()
{
this.crReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
crReportDocument.Load(Server.MapPath("users.rpt"));
DataSet ds = new DataSet();
ds = ListUsers(0, 0);
crReportDocument.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = crReportDocument;
CrystalReportViewer1.DataBind();
}
------------------------------------------------------------------------------------------------
Crystal Enterprise
private void BindReport()
{
crReportDocument.EnterpriseLogonInfo.CmsServer = "..";
crReportDocument.EnterpriseLogonInfo.Password = "..";
crReportDocument.EnterpriseLogonInfo.Username = "..";
crReportDocument.FileName = "..";
crReportDocument.UriIsUserEditable = false;
CrystalReportViewer1.ReportSource = crReportDocument;
CrystalReportViewer1.DataBind();
}
DataView.Find
DataView dv=new DataView();
dv=ds.Tables[0].DefaultView;
dv.Sort=ID or Value;
string result=dv[dv.Find(ID or Value)]["ColumnName"].ToString()
dv=ds.Tables[0].DefaultView;
dv.Sort=ID or Value;
string result=dv[dv.Find(ID or Value)]["ColumnName"].ToString()
Friday, May 25, 2007
SubString in SQL Server for comma separated
CREATE PROCEDURE dbo.usp_UpdateCountryUser
(@UserID int , @CountryIds varchar(1000))
AS
BEGIN
DECLARE @intPos INT, @SubStr varchar(1000)
SET @CountryIDs=REPLACE(@CountryIDs,' ','')
SET @intPos=CHARINDEX(',',@CountryIDs)
WHILE @intPos >0
BEGIN
SET @SubStr=SubString(@CountryIDs,0,@intPos)
--delete, insert, update sql statement here
SET @CountryIDs=SUBSTRING(@CountryIDs, LEN(@SubStr) + 2, LEN(@CountryIDs) - LEN(@SubStr) + 1)
SET @IntPos = CHARINDEX(',', @CountryIDs)
END
END
(@UserID int , @CountryIds varchar(1000))
AS
BEGIN
DECLARE @intPos INT, @SubStr varchar(1000)
SET @CountryIDs=REPLACE(@CountryIDs,' ','')
SET @intPos=CHARINDEX(',',@CountryIDs)
WHILE @intPos >0
BEGIN
SET @SubStr=SubString(@CountryIDs,0,@intPos)
--delete, insert, update sql statement here
SET @CountryIDs=SUBSTRING(@CountryIDs, LEN(@SubStr) + 2, LEN(@CountryIDs) - LEN(@SubStr) + 1)
SET @IntPos = CHARINDEX(',', @CountryIDs)
END
END
Response Time of Major Shopping sites
http://www.optimizationweek.com/reviews/shopping/
I was searching to find out industrial standard response time of a web application and finally landed up to this. More than 20 secs, optimize the page
I was searching to find out industrial standard response time of a web application and finally landed up to this. More than 20 secs, optimize the page
Thursday, May 24, 2007
Wednesday, May 23, 2007
Direct tnsNames.ora style ConnectionString for Oracle from .NET
1. tnsping (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=))(CONNECT_DATA=(SERVICE_NAME=)))
2. if step 1 is successful, then
ConnectionString="Server=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=))(CONNECT_DATA=(SERVICE_NAME=)));uid=;pwd=;"
3. Location for tnsNames.ora file C:\oracle\ora817\network\ADMIN
2. if step 1 is successful, then
ConnectionString="Server=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=))(CONNECT_DATA=(SERVICE_NAME=)));uid=;pwd=;"
3. Location for tnsNames.ora file C:\oracle\ora817\network\ADMIN
Monday, May 21, 2007
Thursday, May 17, 2007
Scheduling of DTS in SQL Server
You can use windows scheduler, or you can use dtsrunui.exe. SQL Server Agent has to run for running the job in SQL Server
Friday, May 11, 2007
Context Menus in ASP.AJAX.NET
There is a sample using AJAX.ASP.NET
http://www.binaryintellect.net/products/displayproductdetails.aspx?productid=8
http://www.binaryintellect.net/products/displayproductdetails.aspx?productid=8
returning output parameter values of Stored Procedure from DAAB of Ent. Library
Database db = GetDbConnection(0);
DbCommand dbCmd = db.GetStoredProcCommand("spName");
db.AddInParameter(dbCmd, "@ProductID", DbType.Int32, 1);
db.AddOutParameter(dbCmd, "@SubmID", DbType.Int32, 0);
queryOut = db.ExecuteNonQuery(dbCmd);
return Convert.ToInt32(db.GetParameterValue(dbCmd, "@SubmID"));
DbCommand dbCmd = db.GetStoredProcCommand("spName");
db.AddInParameter(dbCmd, "@ProductID", DbType.Int32, 1);
db.AddOutParameter(dbCmd, "@SubmID", DbType.Int32, 0);
queryOut = db.ExecuteNonQuery(dbCmd);
return Convert.ToInt32(db.GetParameterValue(dbCmd, "@SubmID"));
DataSet.Merge will merge rows or columns?
Yes. it will merge rows and columns of two datasets. For rows merge, Table Name and Column Names in both datasets should be the same. For columns merge, Column Names should be different, then new column will be added to the merged dataset.
http://forums.asp.net/thread/1693004.aspx
http://forums.asp.net/thread/1693004.aspx
accessing different SQL Server in stored procedures
Issue: If you have another database in the same server, you can write "select * from secondDB.dbo.TableName". But if you want to access another database which is in separate server, then what should we do?
Resolution: I have used "EXEC sp_addlinkedserver with OpenQuery" of SQL Server 2000. I don't know any other better method.
Resolution: I have used "EXEC sp_addlinkedserver with OpenQuery" of SQL Server 2000. I don't know any other better method.
Intellisense in web.config is not working
remove this from configuration tag.
xmlns=http://schemas.microsoft.com/.NetConfiguration/v2.0
http://weblogs.asp.net/scottgu/archive/2005/12/02/432077.aspx
xmlns=http://schemas.microsoft.com/.NetConfiguration/v2.0
http://weblogs.asp.net/scottgu/archive/2005/12/02/432077.aspx
Element 'UpdatePanel' is not a known element. This can occur if there is a compilation error in the Web site
This is the issue with Visual Studio 2005. Install SP1. Else do this as per this link.
http://weblogs.asp.net/scottgu/archive/2006/11/16/gotcha-lost-html-intellisense-within-asp-net-ajax-controls.aspx
I use the first method. Sometimes I have to open Master file, sometimes I have to close the master file from VS.NET, then only all the intellisenses are working.
Changing web.config to ajax tag, required me to change in every place, so I dont prefer this web.config solution.
http://weblogs.asp.net/scottgu/archive/2006/11/16/gotcha-lost-html-intellisense-within-asp-net-ajax-controls.aspx
I use the first method. Sometimes I have to open Master file, sometimes I have to close the master file from VS.NET, then only all the intellisenses are working.
Changing web.config to ajax tag, required me to change in every place, so I dont prefer this web.config solution.
Tuesday, May 08, 2007
Server Events for the controls inside Modal Popup Panel
If you have Ok button inside Modal Pop up Panel, How to post back to the server on OK_Click? By default popup does not post back. You have to use UseSubmitBehaviour=false in Ok Button
Subscribe to:
Posts (Atom)