Total Pageviews

Friday, December 10, 2010

Send html page directly to the default printer without showing print dialog box

[if gte mso 9]> Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>title>
<object classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" id="WB" width="0">
object>

<script language="JavaScript">
DA = (document.all) ? 1 : 0
script>

<script language="VBScript">

'sub print()
'OLECMDID_PRINT = 6
'OLECMDEXECOPT_DONTPROMPTUSER '= 2
'OLECMDEXECOPT_PROMPTUSER '= 1
'on error resume next
'IE4 object has different command structure
'if DA then
'call 'WB.ExecWB(OLECMDID_PRINT, 'OLECMDEXECOPT_DONTPROMPTUSER,1)
'else
'call 'WB.IOleCommandTarget.Exec(OLECMDID_PRINT ',OLECMDEXECOPT_DONTPROMPTUSER,"","")
'end if

'end sub

'This will be interpreted during loading.
'It will write out the correct webbrowser object depending
'on the browser version. To be sure it works, make sure you
'include this script block in between the body tags.

if DA then
'this must be IE4 or greater
wbvers="8856F961-340A-11D0-A96B-00C04FD705A2"
else
'this must be IE3.x
wbvers="EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B"
end if

document.write ""

script>

<style type="text/css">
#form1
{
height: 275px;
}
style>
head>
<%----%>
<body>
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" onclientclick="window.print();"
Text="Button" />
<br />
<iframe src="Test.pdf" width="500px" height="500px">
this is test
iframe>
form>
body>
html&gt;

Thursday, October 7, 2010

Callback vs Postback

http://stackoverflow.com/questions/365100/difference-between-a-postback-and-a-callback

Thursday, September 23, 2010

Async File Upload control - Close file problem

Add this under section <system.web> section

<httpruntime maxrequestlength="51200" requestLengthDiskThreshold="4096" />



Tuesday, September 14, 2010

Disable a Button

override protected void OnInit(EventArgs e)
{
Button1.Attributes.Add("onclick", "javascript:" +Button1.ClientID + ".disabled=true;" + this.GetPostBackEventReference(Button1));
base.OnInit(e);
}


protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(2000);


}

Wednesday, September 1, 2010

List SQL table column as rows

use TestDB

select COLUMN_NAME 'All_Columns' from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='tblTest'

Thursday, August 19, 2010

SQL Server - Ripping time part

-- Get current date (without time) as string:
SELECT CONVERT( CHAR(8), GetDate(), 112)

-- Get current date (without time) as date:
SELECT CAST( CONVERT( CHAR(8), GetDate(), 112) AS DATETIME)

Monday, August 16, 2010

ASP.NET Page Life Cycle Events

Page Life Cycle Events:


1. PreInit: This is the first real event you might handle for a page. You typically use this event only if you need to dynamically (from code) set values such as master page or theme. This event is also useful when you are working with dynamically created controls for a page. You want to create the controls inside this event.

2. Init: This event fires after each control has been initialized. You can use this event to change initialization values for controls.

3. InitComplete: Raised once all initializations of the page and its controls have been completed.

4. PreLoad: This event fires before view state has been loaded for the page and its controls and before PostBack processing. This event is useful when you need to write code after the page is initialized but before the view state has been wired back up to the controls

5. Load: The page is stable at this time; it has been initialized and its state has been reconstructed. Code inside the page load event typically checks for PostBack and then sets control properties appropriately. The page’s load event is called first. Then, the load event for each child control is called in turn (and their child controls, if any). This is important to know if you are writing your own user or custom controls.

6. Control (PostBack) events: ASP.NET now calls any events on the page or its controls that caused the PostBack to occur. This might be a button’s click event, for example.

7. LoadComplete: At this point all controls are loaded. If you need to do additional processing at this time you can do so here.

8. PreRender: Allows final changes to the page or its control. This event takes place after all regular PostBack events have taken place. This event takes place before saving ViewState, so any changes made here are saved.

9. SaveStateComplete: Prior to this event the view state for the page and its controls is set. Any changes to the page’s controls at this point or beyond are ignored. This is useful if you need to write processing that requires the view state to be set.

10. Render: This is a method of the page object and its controls (and not an event). At this point, ASP.NET calls this method on each of the page’s controls to get its output. The Render method generates the client-side HTML, Dynamic Hypertext Markup Language (DHTML), and script that are necessary to properly display a control at the browser. This method is useful if you are writing your own custom control. You override this method to control output for the control.

11. UnLoad: This event is used for cleanup code. You use it to release any managed resources in this stage. Managed resources are resources that are handled by the runtime, such as instances of classes created by the .NET common language runtime.