Friday, September 29, 2006

How to: Precompile ASP.NET Web Sites for Deployment

When you precompile an ASP.NET Web site for deployment you create a layout containing assemblies and other information that you can then copy to a production server. A Web site that is precompiled for deployment gives you the ability to create a compiled version of the site that can be deployed to a production server without source code.
You can choose to precompile either code and .aspx pages, or just the code. If you precompile only the code, you can update the user interface of the site without having to recompile the entire site.
The procedures in this topic use the switches and parameters of the ASP.NET Compilation Tool (Aspnet_compiler.exe). For more information about this tool, see ASP.NET Compilation Tool (Aspnet_compiler.exe).
For more information about precompilation, see ASP.NET Web Site Precompilation.
To precompile an ASP.NET Web site for deployment
Open a command window and navigate to the folder containing the .NET Framework.
The .NET Framework is installed in the following location.
Copy Code%windir%\Microsoft.NET\Framework\version
Run the aspnet_compiler command by typing the following at a command prompt, specifying the source as either a virtual path or physical path and the target folder for the compiled Web site.
Copy Codeaspnet_compiler -v virtualPath targetPath
If your Web site is not an Internet Information Services (IIS) application and therefore has no entry in the IIS metabase, used the following value for the -v switch.
Copy Codeaspnet_compiler -p physicalOrRelativePath -v / targetPath
In this case, the physicalOrRelativePath parameter refers to the fully qualified directory path in which the Web site files are located, or a path relative to the current directory. The period (.) operator is allowed in the physicalOrRelativePath parameter. The -v switch specifies a root that the compiler will use to resolve application-root references (for example, with the tilde (~) operator). When you specify the value of / for the -v switch the compiler will resolve the paths using the physical path as the root.
The targetPath parameter is a physical path to the destination directory
To precompile an ASP.NET Web site for deployment and update
Open a command window and navigate to the folder containing the .NET Framework.
The .NET Framework is installed in the following location.
Copy Code%windir%\Microsoft.NET\Framework\version
Run the aspnet_compiler command by typing the following at a command prompt, specifying the source as either a virtual path or physical path, the target folder for the compiled Web site, and the -u switch indicating you want to compile the site for deployment and update.
Copy Codeaspnet_compiler -p physicalOrRelativePath -v / targetPath -u


Ref: http://windowssdk.msdn.microsoft.com/en-us/library/ms227976.aspx

Keep Session alive

<BroJax:SessionLeaseExtender
runat="server" id="ctlSessionLeaseExtender"
LeaseTime="2"
ClientCallbackFunction="sessionExtended();">
</BroJax:SessionLeaseExtender>

ref: http://www.netomatix.com/Development/SessionLeaseControl.aspx

Thursday, September 28, 2006

Install IIS & IIS Tips

Install IIS6.0
Go to manager server and then click on "Add or Remove role", follow the setup wizard will install the IIS6.0.

Ref: http://www.iis-resources.com/modules/AMS/article.php?storyid=262

Wednesday, September 27, 2006

Prevent Session Time out

private void Page_Load(object sender, System.EventArgs e)
{
this.AddKeepAlive();
}
private void AddKeepAlive()
{
int int_MilliSecondsTimeOut = (this.Session.Timeout * 60000) - 30000;
string str_Script = @"
<script type='text/javascript'>
//Number of Reconnects
var count=0;
//Maximum reconnects setting
var max = 5;
function Reconnect(){

count++;
if (count < max)
{
window.status = 'Link to Server Refreshed ' + count.toString()+' time(s)' ;

var img = new Image(1,1);

img.src = 'Reconnect.aspx';

}
}

window.setInterval('Reconnect()',"+ _
int_MilliSecondsTimeOut.ToString()+ @"); //Set to length required

</script>

";

this.Page.RegisterClientScriptBlock("Reconnect", str_Script);

}


<%@ OutputCache Location="None" VaryByParam="None" %>
<html>
</html>



ref: http://www.codeproject.com/aspnet/Reconnect.asp

Saturday, September 23, 2006

ASP.NET Tips

DataGrid Custom Paging
http://samples.gotdotnet.com/quickstart/util/srcview.aspx?path=/quickstart/aspplus/samples/webforms/ctrlref/webctrl/datagrid/datagrid11.src


http://samples.gotdotnet.com/quickstart/aspplus/samples/webforms/ctrlref/webctrl/datagrid/doc_datagrid.aspx

Develop data grid paging
ref: http://dotnetjunkies.com/Tutorial/EA868776-D71E-448A-BC23-B64B871F967F.dcik

How to use the data adapter
http://www.codeproject.com/cs/database/sqldawithoutsqlcb.asp

Authentication and Authorization in ASP.NET
Authentication is the process of identification and validation of a user's credentials. After the identity is authenticated, a process called authorization determines whether that identity has access to a particular resource. This article discusses both these concepts in detail.

ref: http://aspalliance.com/907

Bubbled Event
ref: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconbubblingcommandevent.asp

ref: http://aspnet.4guysfromrolla.com/articles/051105-1.aspx

How to use the Validator
ref: http://aspnet.4guysfromrolla.com/articles/073102-1.aspx

How to upload Large File



In the Machine.config file, change the maxRequestLength attribute of the <httpruntime>configuration section to a larger value. This change affects the whole computer.

In the Web.config file, override the value of maxRequestLength for the application. For example, the following entry in Web.config allows files that are less than or equal to 8 megabytes (MB) to be uploaded:<httpruntime maxrequestlength="8192">


ref:http://support.microsoft.com/kb/295626/

Friday, September 22, 2006

Could not load file or assembly 'Microsoft.mshtml, Version=7.0.3300.0

Could not load file or assembly 'Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.


I found two ways to fix the problem. First, you can copy Microsoft.mshtml.dll into the application directory. Alternatively, you can run vs_piaredist.exe, which is in \program files\common files\merge modules on machines with vs 2005 installed.

Install asp.net for iis

If the iis is installed after .net framework install, the command Aspnet_regiis.exe -i need to run under the dos shell. It can be found under windows/microsoft.net

Thursday, September 21, 2006

Java Script tips

close window with javascript

Close Window






Create Date Time in javascript
var datetime = new Date();

JavaScript Intellisense

Changing this targetSchema property tells the Visual Studio .NET editor what browser I would like my Intellisense to be compatible with. When testing javascript code specific to Netscape I select the Netscape Navigator 4.0 option. Then for example, when I type the javascript keyword/object document followed by the usual dot (period), I get the Intellisense populated with all the Netscape Navigator 4.0 compliant properties and methods. The same is true when I select the Internet Explorer 5.0 option.


ref: http://blogs.crsw.com/mark/articles/648.aspx

ref: http://www.c-point.com/javascript_editor.php

Capture Mouse Position in JavaScript
var e = window.event;
var x = e.screenX;
var y = e.screenY;

JavaScript PostBack
onmousedown="javascript: <%#getPostBack()%>;"

protected string getPostBack()
{
return this.Page.GetPostBackEventReference(this, "@@@@@buttonPostBack"");
}

protected void Page_Load(object sender, System.EventArgs e)
{
// this Is a postback, then we care
if( this.IsPostBack )
{
// determine who caused the post back
string eventArg = Request[ "__EVENTARGUMENT" ];
// if null ( could it ever be null? )
if( eventArg != null )
{
// this post back can occur if we raise the event or if the Web Form itself raises the event.
// therefore, i always like to put something in the eventarg that lets me identify it as an event
// that i raised. i use @@@@@. but you can use whatever you like, just make sure it is unique.

// i also like to make the ClientId part of the value if i am posting back within a user control or
// custom control. including the ClientId in a user or custom control enables me to programmatically
// determine which instance of the control executed the postback. again we do this because all postbacks
// for all instances of all controls on the page are being funneled through this one method.
int offset = eventArg.IndexOf( "@@@@@" );
if( offset > -1 )
{
// this is an event that we raised. so do whatever you need to here.
}
}
}
}

ref: http://weblogs.asp.net/mnolton/archive/2003/06/04/8260.aspx

Wednesday, September 20, 2006

Atlas Learning Experiences - Ajax

Atlas toolkits demo and document site
http://atlas.asp.net/atlastoolkit/CascadingDropDown/CascadingDropDown.aspx

Atlas document and quick start

http://atlas.asp.net/docs/Client/default.aspx


How to debug atlas
http://atlas.asp.net/docs/Overview/debug.aspx

DateTime Picker Control
http://atlas.asp.net/docs/Walkthroughs/Samples/datepicker.aspx

How do I asp.net ajax?
http://ajax.asp.net/default.aspx?tabid=47&subtabid=478#howdoi

How to Define a theme

1. Add a theme
2. Add a skin under the theme
3. Add a asp.net web page and drag and drop the asp.net controls to the web page and select the style you wanted and then copy and paste them to the skin file. remember to take out the ID and text
4. Add stylesheet under the theme
5. put Theme="EntryTheme" at <@Page ..>
ex: <%@ Page Language="C#" AutoEventWireup="true" Theme="EntryTheme" CodeFile="DailyLogEntry.aspx.cs" Inherits="DailyLog_DailyLogEntry" %>

Notes: Only the asp.net controls are allowed in the skin file. The html element does not allow in the skin file. But it can be in the stylesheet.

How to create style for html element

The samples for creating the style for html element are followings:

body
{
background-color:#ACC2EE;
}
input
{
height:16px;
font-size:12px;
}
select
{
height:16px;
font-size:12px;
}

to define an input button or input image create the style as followings:

input.button
{
height:20px;
}
input.image
{
height:20px;
}
then add the following line into style:
input
{
-mso-attribute-selector-hack:expression( addAttributeName(this) );
height:15px;
font-size:12px;
}

finally, add the following javascript into asp.net page header

<script>
function addAttributeName(node) {
if (node.type&&!(node.className&&node.className.indexOf(node.type)>=0)) {
node.className = node.type;
}
}
</script>


The image input type can also define with the followings:

input.LookupButton
{
height:20px;
}

and set the class="LookupButton"

ex:

<input type="image" align="absMiddle" id="Lookup" height="21px" src="../Images/look.gif" runat="server" class="LookupButton" />

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

about the error:

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).


Use <%# this.txtCompany.ClientID %> to replace <%= this.txtCompany.ClientID %> to fix the problem.
Ref: http://west-wind.com/weblog/posts/5758.aspx

Thursday, September 14, 2006

How to Bind XML data to gridview

Here I browsed to the XML file that I added to the application to be the source of the data. I didn't specify any transform file because this XML file is already in the format that I want, but you can supply the name of a standard XSLT file here if you want. The third box here is for an XPath expression that specifies the nodes in the XML file that will supply the data for the data source. The expression Names/Name says that I'm binding the contents of the nodes.



http://www.developer.com/db/article.php/3553881

Wednesday, September 13, 2006

ATLAS & ASP.NET Tutorial

Atlas tutorial http://atlas.asp.net/docs/Atlas/default.aspx


ASP.NET BEGINNERS
http://www.asp.net/learn/videos/default.aspx?tabid=63

Debug javascript in IE

To do this, fire up Internet Explorer (all examples will be through Internet Explorer here, though other browsers are just as valid) and go to Tools > Internet Options> Advanced Tab. Under the Advanced Tab you'll see two checkboxes that must be unchecked: "Disable Script Debugging (Internet Explorer)" and "Disable Script Debugging (Othe).

Set "debugger;" before the row that you want to debug.

The page will fire up, but before you do anything on the page itself, go back to Visual Studio and go to Debug > Windows > Script Explorer. What will happen is a script explorer window will dock within Visual Studio showing you the running processes whose scripts you can attach to. The window looks like this on my machine:


reference link:http://www.ben-rush.net/blog/CommentView,guid,b20a27b8-66ba-43e5-b0d6-4aa11c76d739.aspx



ref: http://www.jonathanboutelle.com/mt/archives/2006/01/howto_debug_jav.html

open modal dialog in IE

The following code will open a modal dialog in IE with jscript.

window.showModalDialog("SMD_target.htm, null,"dialogHeight: 250px; dialogWidth: 200px; dialogTop: 200px; dialogLeft: 200px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;");
ref: http://msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialog.htm
ref: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/showmodaldialog.asp
ref: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/om/windows_frames_dialogs.asp

ref:http://www.devx.com/tips/Tip/14231Put <base target="_self"> in the header of the aspx page will make the page staying in the dialog when do the postback.