Thursday, September 13, 2007

Client Side GridView

This is the AJAX Client side Gridview with paging, sorting, drag and drop

http://www.codeplex.com/AjaxDataControls

CollapsiblePanel expand / collapse

From javascript

$find(BehaviorID).expandPanel();
$find(BehaviorID).collapsePanel();

in Code Behind


cpeLeft.Collapsed = false;
cpeSide.Collapsed = true;
cpeLeft.ClientState = "false";
cpeSide.ClientState = "true";

Friday, August 31, 2007

Update Panels are dangerous

http://encosia.com/index.php/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous/

IsDate equivalent in C#

We need not load the entire Microsoft.VisualBasic.Information.IsDate() for this function alone...

We can use the following the basepage

public static bool IsDate(object Expression)
{
string strDate = Expression.ToString();
try
{
DateTime dt = DateTime.Parse(strDate);
if (dt != DateTime.MinValue && dt != DateTime.MaxValue)
return true;
return false;
}
catch
{
return false;
}
}

Thursday, August 30, 2007

MaskedEditExtender + Mask for MMM d, yyyy format

Mask=99/99/9999 will give makededit mask to enter mm/dd/yyyy in textbox. I have tried with LLLL 9, 9999. No improvement. Looks like there is an issue in AJAXControlToolkit..

http://forums.asp.net/t/1145071.aspx

HTTP Keep-Alives Enabled

When it is enabled, server will make strong attempt to keep the connection open between request, thus improves the performance.

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/ea116535-8eb9-4c80-8b14-b34418dbfe42.mspx?mfr=true

AJAX History Control

http://www.asp.net/learn/ajax-videos/video-149.aspx

but this is with AJAX Futures Microsoft.Web.preview.dll - Not with AJAX Toolkit.

Wednesday, August 29, 2007

Failed to start monitoring file changes in ASP.NET 1.0

Occurs in VS.NEt 2003, .NET 1.1, ASP.NET 1.0

Resolution : Give NetworkService and ASPNET access to the folder

http://support.microsoft.com/kb/317955

Tuesday, August 28, 2007

EXECUTE permission denied on object 'sp_sdidebug', database 'master', owner 'dbo'

Resolution:

In Visual Studio 2005, Disable T-SQL debugging if you dont want to debug SQL Queries. You can check Managed Code, so you can debug the C# code.

Wednesday, August 22, 2007

Load Test Web Applications Using Visual Studio Team System

Microsoft ACT requires VS.NET 2003 to be installed. For ASP.NET 2.0 applications, you can use VS.NET 2005 Team Suite for Load Test

This is good article on load testing using VS.NET 2005 Team Suite http://www.codeplex.com/PerfTesting/Wiki/View.aspx?title=How%20To:%20Load%20Test%20Web%20Applications%20Using%20VS.NET%202005&referringTitle=Visual%20Studio%20Team%20System%202005%20Index

HTTP 403.9 - Access Forbidden: Too many users are connected

Mostly if you use Windows 2000 or XP Professional, you need to deploy your application in Windows 2003 server..

http://support.microsoft.com/kb/262635

Maximum Number of Concurrent Connections to IIS6

if the OS is Windows 2000 or XP, then maximum no of concurrent users is limited to 10

if you have Windows 2003 server, it depends on the server memory and application caching..

http://blogs.msdn.com/david.wang/archive/2006/04/12/HOWTO-Maximize-the-Number-of-Concurrent-Connections-to-IIS6.aspx

http://support.microsoft.com/kb/262635

Tuesday, August 21, 2007

Cannot find template with id testproject-v1-wordManualTest for cSharp test Project

VS.NET Team Suite - After installing, I was not able to see WebTest, LoadTest templates in the test project.

Resolution:
1. Run devenv /resetuserdata in VS.NET command prompt

2. Run devenv /installvstemplates in VS.NET command prompt

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1559338&SiteID=1

http://geekswithblogs.net/ehammersley/archive/2005/11/08/59451.aspx

Friday, August 17, 2007

Request Format is unrecognized

Enable

add name="Documentation"

in Web.Config

Limiting the Web Services Protocols

Open Web.Config

webServices
protocols
remove name="HttpPost"
remove name="HttpGet"
remove name="Documentation"
add name="HttpSoap"
/protocols
/webServices>

If you set web.config like this, it will allow only Soap protocol to access the web services. Through normal Internet Explorer, you cannot pass any parameters to the web services. Better security for production web services..

Disable WSDL File Generation for Web Services

Open Web.config

web services
protocols
remove name="Documentation"

This will disable WSDL File generation by WSDL.exe

Tuesday, August 14, 2007

Horizontal Accordian control

AJAX Accordian Control expands vertically. I have implemented horizontal expansion through CollapsiblePanel Extenders by


ExpandDirection="Horizontal" TargetControlID="leftDetail" ExpandControlID="sideHeader"
CollapsedImage="~/images/left.jpg" ExpandedImage="~/images/right_dull.jpg" CollapseControlID="leftHeader"
runat="server" Collapsed="true">

ExpandDirection="Horizontal" TargetControlID="sideDetail" ExpandControlID="leftHeader"
CollapsedImage="~/images/right.jpg" ExpandedImage="~/images/right_dull.jpg" CollapseControlID="sideHeader"
runat="server" Collapsed="false">

UpdatePanelAnimationExtender - OnUpdating always executed

As per
http://www.asp.net/AJAX/Control-Toolkit/Live/UpdatePanelAnimation/UpdatePanelAnimation.aspx

It is important to note that because of the UpdatePanel architecture, the OnUpdating animation will always play when any partial postback starts, but the OnUpdated animation will only play at the end of a partial postback if its UpdatePanel was changed (note: setting the UpdatePanel's UpdateMode="Always" will ensure the OnUpdated animation plays when every partial postback completes)

So we can't have UpdatePanelAnimationExtender for individual UpdatePanel in a page..

Tuesday, July 31, 2007

SQL Server 2005 Features comparison

Features comparison of different editions of SQL Server 2005

http://www.microsoft.com/sql/prodinfo/features/compare-features.mspx

AJAX Futures July 2007 release

Again another release within last 2 months. Waiting for these cooooool features in ASP.NEt

1. Dynamic Language Runtime - IronPython for ASP.NET and Managed JScript support
2. Dynamic light weight Data controls for ASP.NET
3. SilverLight support inside ASP.AJAX.NEt

New Controls in Futures

AJAX Futures May 2007 release has some additional controls like ListView and DetailView which supports concurrent update and asynchronous calls from javascript. It is coool.. but it is changing from release to release from Microsoft. So we have to wait for production release or next version of AJAX web Extension. Till then use updatepanel and partial postbacks...

gridview deleting rows by javascript web method calls

After deleting, updating rows of the gridview, if you want to update the gridview display, you can have a Delete web method call from javascript and RowDeleting method, you can refresh / rebind the gridview.

Reason for this.
1. It has lower overheads compared to direct ItemCommand delete, because ItemCommand method will try to find the control from gridview and get the value of the ID of the grid by iterating from row to row and column to column.

2. PageMethod is a static webmethod, so we can't have the access to the page controls

Asynchronous calls from javascript

Direct calls from javascript has async calls. Suppor if you have 3 web method calls from javascript, all the 3 calls are processed at the same time. So if the first method takes long time than the other two, it will return the results of method2 and method3 before method1

Programmatic update of the specific updatepanel

If you want to update a specific updatepanel after your database modification programmatically, you can do it by UpdatePanel1.Update()

Export to Excel from UpdatePanel

If you gridview inside update panel, then when you export to excel on button click using Response.ContentType and Response.write method, you will get an error of Sys.Page... error. To overcome this, in the triggers section, have
asp:PostBackTrigger ControlID=xlsExport .

CollapsiblePanelExtender Flicker

Make sure that you have the same space in the browser / div width.

Check for any additional rendering tags like td, and attributes like width, height in the both panels.

Wednesday, July 25, 2007

ModalPopup for GridView Editing rows

http://mattberseth.com/blog/2007/07/modalpopupextender_example_for.html

The simple one is making one dummy button to assign targetcontrolID property of the Modal Popup Extender.

Monday, July 16, 2007

Error Handling for AJAX.ASP.NET update panel

http://ajax.asp.net/docs/tutorials/CustomizingErrorHandlingforUpdatePanel.aspx

IE hangs in AJAX Update Panel pages

Badly designed UpdatePanel may cause this issue in the popup IE page. For example, you have UpdatePanel in the start of the page. Then have a window.close button inside this UpdatePanel. Just close and open this 2 or 3 times from base IE. After that it hangs.

Resolution:

1. close button should not post back, so you can have return false in OnClientClick event
2. close button should be outside of update panel
3. call Sys.WebForms.PageRequestManager.getInstance().abortPostBack() on body unload

ModalPopup Flicker

This flicker at postback can be avoided by

div id="divProgress" runat="server" style="display: none"

asp:Panel runat="server" ID="pnUpdateProgress" Width="400px" BackColor="Gainsboro"
Height="100px"

and making divProgress display:block during the display of modalpopup

restartOnExternalChanges for appsettings

1. If you want to do this, you will have to change it in machine.config. By default, it is specified as true in machine.config.

2. If the appsettings are stored in external file like mySettings.config, then any changes to mySettings.config will not get effected if you specify appsettings "file" attribute. But if you specify "configSource" attribute, it is effected immediately.

Free Graph Control for ASP.NET 2.0

http://zedgraph.org/wiki/index.php?title=Main_Page

Cool Controls are available here. Another good open source from SourceForge

Leaving the page when Update Panel is processing

When updatepanel is processing, we may not be able to leave that page. If you forcefully leave that page, then memory leak or long pending server side process will take place and IE will hang for some time.

Resolution:
1. Have UpdateProgress and have "Abort Process" button and call


function AbortPostBack() {
if (Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()) {
Sys.WebForms.PageRequestManager.getInstance().abortPostBack();
} }

2. Write Javascript on body unload and call AbortPostBack() method. You may have this in Master Page.

Debugging Javascript in VS.Net

write debugger; in the javascript code. And UnCheck - Disable Script DeBugging in IE-Tools-Internet Options-Advanced.

That is it, you can do F10, F11 in VS.NET now.

Friday, July 13, 2007

AJAX Partial Postback event lifecycle

http://ajax.asp.net/docs/tutorials/UpdatePanelClientScripting.aspx

initializeRequest
beginRequest
pageLoading
pageLoaded
endRequest

so instead of page load, page unload method these events will be fired

Friday, July 06, 2007

Finding aspx pagename in ASP.NEt

System.IO.Path.GetFileName(Request.ServerVariables ["SCRIPT_NAME"])

Friday, June 29, 2007

Simple ASP.NET Page Lifecycle

Here are the methods the runtime will look for when AutoEventWireup is true.

Page_PreInit
Page_Init
Page_InitComplete
Page_PreLoad
Page_Load
Page_LoadComplete
Page_DataBind
Page_SaveStateComplete
Page_PreRender
Page_PreRenderComplete
Page_Unload
Page_Error
Page_AbortTransaction
Page_CommitTransaction

Thursday, June 21, 2007

PageMethods + Static Methods in AJAX

Javascript can call code behind code, but the code behind method should be a static method and decorated with [WebMethod]

so After you call this webmethod, how do we refresh the page.. (sometimes you need to refresh the page to display the latest values after deleting a record from a grid).

Here are the steps;

1. Write javascript return method in OnClientClick of button
2. Call PageMethods.MethodName
3. Write return true in OnComplete method, this will call OnClick method of button
4. Write refresh, grid rebind methods in the server OnClick Method. This will post back and get the latest record to grid.

Wednesday, June 13, 2007

To Show Modal Popup in the page load

ModalPopupExtender.Show() in the Page_Load()

and to stop this behaviour on every page postback

1. Place it in IsPostBack==false condition
2. Place this in the updatePanel.


Grouping of rows in GridView

http://blogs.msdn.com/mattdotson/articles/541795.aspx

works well for asp:BoundField

Error : Client found response content type of 'text/html', but expected 'text/xml'

This error is from the proxy of web services

Checked the output of webservices, it returned normal text message instead of xml file. Actually it was returning "The requested security package does not exist "

All the application in the App pool returned this error,

Resolution: Had to do IISReset :-(

GridView : Fixed Headers

http://www.dotnetbips.com/articles/displayarticledetails.aspx?articleid=532

style.FixedCell
{
position: relative;
top: 0px;
}

Will work well if you dont have any divs on the header.

Error: An extender can't be in a different UpdatePanel than the control it extends

Resolution: Place the related panels and extenders together in the same place. I was placing all my extenders at the bottom of the page. Then later on, when the page evolves, I have put number of updatepanels for partial page update and modal popups. Then I have changed my behavior of placing panels and modal popups together in one place. It works and clean html code.!!

Tuesday, June 12, 2007

To Close Calendar in AJAXToolkit:CalendarExtender click

http://forums.asp.net/t/1067091.aspx?PageIndex=2

Step1: Write this in Master Page

function hideCalendar(oCalendar)
{
oCalendar.hide();
oCalendar.get_element().blur();
}

Step2: Include OnClientDateSelectionChanged="hideCalendar" in CalendarExtender AJAX

Monday, June 11, 2007

Microsoft new technologies

http://www.microsoft.com/surface
Cool future organizer / computer??

http://www.microsoft.com/silverlight/default01.aspx
Alternate to Flash

Visual Studio Orcas with System.Linq - Future development and data E/R modelling framework

Creating border around the browser window

http://www.boutell.com/newfaq/creating/windowborder.html

Tuesday, June 05, 2007

DataTable already belongs to another DataSet

DataTable dtProto = new DataTable("DtProto");
dtProto = ds.Tables[0].Copy();
dtProto.TableName="DtProto";

dsMain.Tables.Add(dtProto);

Thursday, May 31, 2007

file and configSource attribute in web.config

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

javascript alert from UpdatePanel

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Record Successfully Saved')", true);

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);

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

Website FileManager

http://www.binaryintellect.net/products/displayproductdetails.aspx?productid=8

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.

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
}

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();
}

Separate config file reference in web.config

WSDL.exe

wsdl.exe /out:myref.cs http://localhost/WebSvc/WebPage.asmx will create proxy class

to_date in Oracle

select * from TableName where startDt>=to_date('1/1/1900', 'mm/dd/yyyy')

to_char in Oracle

select to_char(Start_Date,'Mon dd, yyyy') as StartDt from table

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()

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

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

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

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

Build Google IG like Ajax Start Page in 7 days using ASP.NET Ajax and .NET 3.0

http://www.codeproject.com/Ajax/MakingGoogleIG.asp

very good stuff here

Context Menus in ASP.AJAX.NET

There is a sample using AJAX.ASP.NET

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"));

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

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.

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

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.

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

Wednesday, March 21, 2007

Crystal Reports 10 + ASP.NET 2.0 + Webdings

Webdings font in Crystal Reports 10 in ASP.NET 2.0 displays two images instead of one in Internet Explorer 7 and charcters in Firefox.

Crystal Reports 9 + ASP.NET2.0 works fine.

Resolution: Made images instead of text webdings