6月 21, 2011

視窗縮小在工作列上


.NET 針對這方面的功能使用一個物件去完成,相較於VB6更顯得簡單。
首先必須在.NET From 上面新增一個 NotifyIcon 物件,在 ToolBox 裡面的 Windows Froms 中可以找到此物件。新增完成後,可以將以下程式放到程式碼中執行。

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

With NotifyIcon1
.Icon = New System.Drawing.Icon("C:\Program Files\Microsoft Visual Studio .NET\Common7\Graphics\icons\Writing\BOOK01A.ICO")
.Visible = False
End With

End Sub

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize

If Me.WindowState = FormWindowState.Minimized Then
NotifyIcon1.Visible = True
Me.Visible = False
End If

End Sub

Private Sub NotifyIcon1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick
NotifyIcon1.Visible = False
Me.Show()
Me.WindowState = FormWindowState.Normal
End Sub

6月 18, 2011

3種轉址



1. HTML 的轉址方法:

在 HTML 網頁的 </head> 前加入以下 HMTL 碼,網頁就會自動轉址。
<meta http-equiv="refresh" content="0;url=http://mepopeidia.com" />
其中 content=... 中的 0 是指 0 秒後自動重新整理,並轉址到 "http://mepopeidia.com" 這個 URL。


2. Javascript 的轉址方法:

在 HTML 網頁中原則上是任一地方加入以下 JavaScript 網頁就會轉址。但放在網頁 HTML 碼的開始較有效率(也較有意義)。
<script>document.location.href="http://mepopedia.com";</script>

3. PHP 的轉址方法:
<?php
header('Location: http://mepopedia.com');
exit;
?>

6月 17, 2011

POST




POST我做兩個分別~~一個是ASP.NET~~POST,一個是HTML~POST。

下面這個是ASP.NET,紅色為重點。ID一定要設好~~到時接收時要用的。

直接設BUTTION的POSTBACKURL就行了~~不用寫程式~~就會把TEXT1的值POST過去了。

<form id="form1" runat="server">
<div>

<asp:TextBox ID="Text1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" PostBackUrl="post.aspx" />
</div>
</form>

下面這個是HTML的POST,一樣紅色為重點。

form id="form" method="post" action="post.aspx" enctype="multipart/form-data">

<p>
<input id="Text1" name="Text1" type="text" value="1"/>
<input id="Submit1" type="submit" value="submit" /></p>
</form>

下面這個是用ASP.NET來接收POST的值~~

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.Write(Request.Form("Text1").ToString)
'接收別頁使用post過來的值!!

End Sub

這樣會了吧~~只要就是Request.Form("Text1").ToString就會接收TEXT1的值了。

在來就是~~有時POST時~~中文字會出現亂碼~~重點就是要在在web.config
加上下面的程式碼
就會變中文了

<configuration>
<system.web>
<globalization
fileEncoding="big5"
requestEncoding="big5"
responseEncoding="big5"
culture="zh-TW"
/>
</system.web>
</configuration>



6月 16, 2011

動態時間 time



var timerID = null;
var timerRunning = false;
function stopclock() {
if (timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock() {
stopclock();
showtime();
}
function showtime() {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var dateValue = now.getYear() + 1900 + "年" + (now.getMonth() + 1) + "月" + now.getDate() + "日";
var timeValue = ((hours >= 12) ? " 下午 " : " 上午 ");
timeValue += ((hours > 12) ? hours - 12 : hours);
timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
$('#time').html(timeValue);
timerID = setTimeout("showtime()", 1000);
timerRunning = true;
}
$().ready(function () {
startclock();
});

6月 14, 2011

AJAX

onclientclick="return false;" />

onclientclick="return false;"
false會導致無法呼叫.net的程式

6月 13, 2011

asp.net 光棒


Protected Sub GridView1_RowCreated(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated

If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='red';")
If e.Row.RowState = DataControlRowState.Alternate Then '判定row的型態是替代資料行
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF';")
'滑鼠移開底色恢復
Else
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#EFF3FB';")
'滑鼠移開底色恢復
End If
End If
End Sub

6月 12, 2011

jquery

<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.6.1.min.js" type="text/javascript"></script>
    <script type = "text/javascript" >
        $(document).ready(function () {
            $("a").click(function () { alert("hello!"); return false; }); //對a標籤
            $("#hp").click(function () { alert("hello!"); return false; }); //對ID為HP
            $(".mp").click(function () { alert("hello!"); return false; }); //對class為mp 各自獨立
            $("*").addClass(); //表示所有物件
            //$("#bb1").click(function () { $("#Image1").addClass('css'); }); //套用CSS


            $("#box").hide();
            $("#bb1").click(function () { $("#box").toggle("slow"); });
            //屌光棒
            $("tr").hover(function () { $(this).addClass('color'); }, function () { $(this).removeClass('color'); });


            $("#bb1").click(function () { $("#tb1").attr({ disabled: "disabled" }); });


 


        });
    </script>
    <style type="text/css">
   
    .css{border:1px solid #ababab;}
    .color{background-color: red;}
        .style1
        {
            width: 100%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
   
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <a href="#">dowmload</a>
    <a href="#" id="hp">dowmload2</a>
    <a href="#" class="mp">dowmload3</a><br>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Button ID="bb1" runat="server" Text="Button" /><br>
        </ContentTemplate>
   
    </asp:UpdatePanel>
    <asp:TextBox ID="tb1" runat="server"></asp:TextBox>
    <asp:Image ID="Image1" runat="server" ImageUrl="~/img/logo.png" />
    <div class="asd" id="box">
    123456789
    </div>


 



    </form>
            <table class="style1" id="bg">
                <tr>
                    <td>
                        1</td>
                </tr>
                <tr>
                    <td>
                        2</td>
                </tr>
                <tr>
                    <td>
                        3</td>
                </tr>
                <tr>
                    <td>
                        4</td>
                </tr>
                <tr>
                    <td>
                        5</td>
                </tr>
                <tr>
                    <td>
                        6</td>
                </tr>
            </table>
</body>
</html>