Monday, November 30, 2009

Very Good trick for adding a body onload function for Mater Page.

On MasterPage.master
...
<head>

<asp:contentplaceholder runat="server" id="Headers">

</asp:ContentPlaceHolder>
<script language="javascript">
function mp_onload()
{
if(window.body_onload != null)
window.body_onload();
}
</script>
</head>
<body onload="mp_onload();">


On Content aspx page.
function body_onload() {
....
}


From Alex Wight.

God bless Internet~

Good Artical to deal with the ID in Javascript with Master Page

http://www.codeproject.com/KB/scripting/Masterpage-Javascript.aspx

I hate .NET's Mater Page feature thought. SUCKS~

Thursday, November 5, 2009

Radio button getting 'Object doesn't support this property or method' - javascript

When I add the onclick event to the radio button. I keep getting this 'Object doesn't support this property or method'.

Finally I find out it is because my name of the radio button and the function name in javascript is identical.

Don't use the same name in the future.

Friday, October 2, 2009

SQL 2005 Configuring SQL Job to send email notification if it failed.

SQL 2005 Configuring SQL Job to send email notification if it failed.
This are the simple steps to enable it.
1) Run SQL Server Surface Area Configuration - > Surface Area Configuration for features ->
Select Database Mail - > Check Enable Database mail stored procedures.
2) Open SQL Management Studio - > Management - > Database mail - > Configure SMTP Settings.
3) Go to SQL Server Agent - > Operators - > Create New Operator
4) Go to SQL Job - > In the Notifications, Check email and select the Operator. You can either
select the option to send notification if job fails / succeeds/ completed.
Lastly, don't forget to restart the SQL Agent.

Thursday, October 1, 2009

Open New Window from asp button click

3. Open New Window using ScriptManager
Just on button click, we can register the script to open new window. Let me show this on button click event hander.
protected void btnClick_Click(object sender, EventArgs e)
{
string url = "MyNewPage.aspx?ID=1&cat=test";
string fullURL = "window.open('" + url + "', '_blank', 'height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,titlebar=no' );";
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", fullURL, true);
}

Here we don’t need to add attribute to the button. This just will open new window with the URL specified. And please also note the properties of the new pop-up window.

Friday, September 25, 2009

Visual studio javascript is not updating.

No matter you Clean solution or Rebuild solution. The JavaScript file will not be updated.

Solution:
Download the .js file from IE - type in the JavaScript file path.
LIKE: http://localhost:49573/js/javascript.js
Download it.

Return you solution. The JavaScript file will be updated. I think it remind the IIS JavaScript has been change.

Finally, I found that is because IE browser temporary file is full. Try to delete them and refresh the page.

Thursday, September 24, 2009

SQL: using while loop; variable; UPDATE from SELECT

DECLARE @id as INT
SET @id = 1
WHILE @id <= 15973
BEGIN
UPDATE tblADD_UNEMP SET PRIVATEPAYOCCUPANCY=(SELECT PRIVATEPAYOCCUPANCY/10 FROM tblADD_UNEMP WHERE ID = @id) WHERE ID = @id
SET @id = @id + 1
END