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

Tuesday, September 22, 2009

Get the ImageButton ID from behind code(C#)

ImageButton ibtn = sender as ImageButton;
if (ibtn != null)
{
string theID = ibtn.ClientID;
}

Friday, September 4, 2009

Expression C#

integer: (^([0-9]*|\d*\d{1}?\d*)$)
decimal: ^(\d|-)?(\d|,)*\.?\d*$
Email: \w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

Monday, August 31, 2009

Button bypass Validation

btnlogout.CausesValidation = false;

Sunday, August 23, 2009

千字文网站制作笔记1

 1、800*600下,网页宽度保持在778以内,就不会出现水平滚动条,高度则视版面和内容决定。  2、1024*768下,网页宽度保持在1002以内,就不会出现水平滚动条,高度则视版面和内决定。  3、在ps里面做网页可以在800*600状态下显示全屏,页面的下方又不会出现滑动条,尺寸为740*560左右   4、在PS里做的图到了网上就不一样了,颜色等等方面,因为WEB上面只用到256WEB安全色,而PS中的RGB或者CMYK以及LAB或者HSB的色域很宽颜色范围很广,所以自然会有失色的现象  5、1024*768 下网页的尺寸:width=955,height=600    800*600 下网页的尺寸:width=760,height=420  一般分辨率在800x600的情况下,页面的显示尺寸为:780x428个象素;  分辨率在640x480的情况下,页面的显示尺寸为:620X311个象素;  分辨率在1024X768的情况下,页面的显示尺寸为:1007x600  页面标准按800*600分辨率制作,实际尺寸为778*434px,页面长度原则上不超过3屏,宽度不超过1屏.每个标准页面为A4幅面大小,即8.5X11英寸 全尺寸banner为468*60px,半尺寸banner为234*60px,小banner为88*31px另外120*90,120*60也是小图标的标准尺寸 每个非首页静态页面含图片字节不超过60K,全尺寸banner不超过14K 468*60 全尺寸BANNER 392*72 全尺寸带导航条BANNER 234*60 半尺寸BANNER 125*125 方形按钮 120*90 按钮#1 120*60 按钮#2 88*31 小按钮 120*240 垂直BANNER当然这只是一般意义的对访问者比较友好的设置,很多设计型的页面并不是按照这个尺寸,正所谓艺高人胆大嘛,只要记住一条,站在用户的角度去想,明白自己所设置的尺寸在显示器里的大概样子就可以了。法终究是无定法的。
来源:http://wodejianai121.blog.163.com/blog/static/29522020075226547964/

Friday, July 17, 2009

Set the DefaultButton for a page base on Master Page

Add code to Page_load event.

Page.form.DefaultButton = yourbuttonid.UniqueID;

Wednesday, July 15, 2009

Resolution for no css and pics with authentication on web.config

"<authentication mode="Forms">
<forms name="StaffAssistLogin" loginUrl="./Default.aspx" protection="All" timeout="180"/>

</authentication>


<authorization>
<deny users="?" />
authorization>"

When you put these codes on your web.config file. It will redirect you to the Default.aspx page. But the image and css will not display.

We'd better put the pages which you want to redirect to Default.aspx without authentication in a folder. Let's call it "forms". Then put the code below the line instead of
"<authorization>
<deny users="?" />
authorization>

------------------------------------------------------------------------
<location path="forms">
<system.web>
<authorization>
<deny users="?" />
authorization>
system.web>
location>"

Problem solved.

Monday, February 16, 2009

GridView Control - select without select button

CSS Code:
/* For Hiding Select Column of GridView control*/
.HiddenColumn
{display:none;}


HTML Code:
1 <asp:GridView ID="gvUser" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1" Width="880px" PageSize="20" OnSelectedIndexChanged="gvUser_SelectedIndexChanged" HorizontalAlign="Center" CssClass="form" OnRowDataBound="gvUser_RowDataBound">
2 <Columns>
3 <asp:CommandField ShowSelectButton="True">
4 <HeaderStyle CssClass="HiddenColumn" />
5 <ItemStyle CssClass="HiddenColumn" />
6 </asp:CommandField>
7 <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
8 SortExpression="id" />
9 <asp:BoundField DataField="defirst" HeaderText="defirst" SortExpression="defirst" />
10 <asp:BoundField DataField="delast" HeaderText="delast" SortExpression="delast" />
11 <asp:BoundField DataField="deemail" HeaderText="deemail" SortExpression="deemail" />
12 </Columns>
13 <PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" />
14 <HeaderStyle ForeColor="White" />
15 </asp:GridView>

C# Behind Code:
protected void gvUser_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add(
"onmouseover", "this.style.cursor = 'hand'; this.style.backgroundColor = '#FFCCFF';");
e.Row.Attributes.Add(
"onmouseout", "this.style.backgroundColor='';");
e.Row.Attributes[
"onclick"] = ClientScript.GetPostBackClientHyperlink(this.gvUser, "Select$" + e.Row.RowIndex);
}
}