Sử dụng Cookie trong ASP.NET - Tự học lập trình ASP

Người đăng: ngaybennhau on Thứ Ba, 16 tháng 11, 2010

Bài viết này sẻ hướng dẩn làm một ví dụ nhỏ về Cookie để hiểu được cách thức làm việc của Cookie - Cookie là một file được tạo ra từng web site mà bạn viếng thăm , nó chứa thông tin của bạn trên máy tin của bạn .

Code:

(cookie.aspx)

<script runat="server">
// sử lý dự kiện click nút đăng nhập
protected void bt_login_click(Object Src, EventArgs E)
{
if(tb_username.Text != ""){

// khai báo biến cookie
HttpCookie cookie_username = new HttpCookie("username",tb_username.Text);

// Gán thời gian sống của Cookie là 30 ngày
cookie_username.Expires = DateTime.Now.AddDays(30);

// Thêm Cookie
Response.Cookies.Add(cookie_username);

// làm tươi Response.Redirect("cookie.aspx");
}
}
// sử lý dự kiện click nút Xóa Cookie
protected void bt_delete_click(Object Src, EventArgs E)
{
// khai báo biến cookie
HttpCookie cookie_username = new HttpCookie("username","");
// Gán thời gian sống của Cookie là thời gian hiện tại
cookie_username.Expires = DateTime.Now;
// Thêm Cookie
Response.Cookies.Add(cookie_username);
// làm tươi
Response.Redirect("cookie.aspx");
}
</script>
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="utf-8" %>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="" method="post" name="form1" runat="server" id="form1">
<!–Kiểm tra nếu biến Cookie username tồn tại thì đăng nhập–>
<%if(Request.Cookies["username"] == null){%>
Tên đăng nhập
<asp:TextBox ID="tb_username" runat="server" />
<asp:Button ID="bt_login" runat="server" OnClick="bt_login_click" Text="Đăng nhập" />
<!–Ngược lại thì hiển thị tên đăng nhập–>
<%}else{%>
Chào, <%=Request.Cookies["username"].Value%>
<asp:Button ID="bt_delete" runat="server" OnClick="bt_delete_click" Text="Xóa Cookie" />
<%}%>
</form>
</body>
</html>

Theo thegioiweb
More about

Reset và thay đổi mật khẩu của thiết bị Verizon FIOS Router

Người đăng: ngaybennhau

Trong bài viết sau sẽ giới thiệu với các bạn những bước cơ bản để reset lại password mặc định của thiết bị router Verizon FIOS nếu như bạn quên mật khẩu truy cập.

Trước tiên, các bạn truy cập vào địa chỉ http://192.168.1.1 như thường lệ qua trình duyệt, sử dụng tài khoản quản lý của bạn khai báo trước đó:


Bất kỳ thiết bị router của Verizon nào cũng có nút Reset ở đằng sau, thông thường sẽ có biểu tượng vòng tròn màu đỏ. Các bạn dùng đầu bút bi hoặc thứ gì đó nhỏ (ví dụ như chiếc tăm), nhấn và giữ nút đó cho tới khi đèn tín hiệu trên router tắt hẳn, rồi hãy bật lại. Quá trình này thông thường mất khoảng 10 – 30 giây:


Và sau khi reset router, việc tiếp theo là sử dụng tài khoản mặc định của thiết bị, bao gồm tên đăng nhập và mật khẩu. Thông thường tên đăng nhập sẽ là admin, còn password sẽ là 1 trong những lựa chọn sau: password, admin, số serial (mỗi thiết bị router đều có dãy số serial ở trên tem chính hãng) hoặc mật khẩu bỏ trống.

Nếu không thành công, bạn hãy thử reset và tiếp tục thử lại lần nữa xem sao. Và dưới đây là bảng thông tin chi tiết về 1 số model router phổ biến, được sử dụng rộng rãi:


Và sau khi đã đăng nhập thành công, bạn cần phải thay đổi mật khẩu mặc định này. Các bạn chọn mục Quick Links > Change Login User Name / Password như hình bên dưới:


T.Anh (theo HowToGeek)


More about

Platinum Hide IP v3.0.4.6

Người đăng: ngaybennhau on Thứ Hai, 15 tháng 11, 2010


Use Platinum Hide IP to keep your real IP address hidden, surf anonymously, secure all the protocols on your PC, provide full encryption of your activity while working in Internet, and much more.


Key Features

• Anonymize Your Web Surfing
Your real IP is hidden when you surf on the Internet, keeping your online activity from being tracked by others.
• Protect Your Identity
Anonymous web surfing enables you to prevent identity thieves from stealing your identity or other personal information, and keep your computer safe from hacker attacks or other risks.
• Choose IP Country and Check IP
Proxy lists of many countries are enabled and you decide to select one country from the Choose IP Country window. You can check the current IP address directly.
• Send Anonymous Emails
Send anonymous emails through any web based mail system such as Gmail, Hotmail, etc.
• Get Unbanned from Forums and Blocked Websites
Change your IP address and then you can get unbanned yourself from any forums or other blocked websites that have ever banned you from.








More about

Windows 7 Manager v2.0

Người đăng: ngaybennhau


A powerful software tool to tweak, optimize, maintain and tune up your Windows 7, it includes over thirty different utilities. It will help your system to be stable, fast, secure and personal. For example, get detailed system and hardware information; Tweak your system to improve windows startup and shutdown speed; tweak your hardware to increase system performance; Find and clean junk files; searches your computer for duplicated files; easily checks registry and repairs incorrectly linked registry entries; Defrag Registry to reduce application response time; Control what is started on Windows startup; Create the quick startup items on Taskbar with the Jump List quick launcher; Tune up Windows 7 boot menu; set context menus of mouse right clicking; customize desktop, menus, toolbar, notifications; Improve desktop, menus, control panel, windows logon securities, enable numerous hidden performance options, disable system updates and error reports; hide and restrict access to drives, specify which applications are not allowed to be executed, encrypt/decrypt and shred files, camouflage folder to hide its content from Windows Explorer, change the location of system folders; Privacy Protector can maintain your personal privacy by eliminating the tracks that you leave behind. 


Optimize Internet connection speed, manager your all shares, search and find opened ports; tweak your IE easily; automatically check invalid URLs in your favorites and parse domain name; show the collection of Windows utilities. Windows 7 Manager has a topnotch, easy-to-use user interface that requires no technical knowledge. It is an excellent companion for Windows 7.










More about

Phân trang Blogger theo kiểu Wordpress

Người đăng: ngaybennhau

Về phân trang thì Blogger chỉ mặc định các nút Older Posts (Bài đăng Cũ hơn), Newer Posts (Bài đăng Mới hơn), Home (Trang chủ) để liên kết đến các bài viết lẫn nhau và kiểu phân trang sơ đẳng này không làm thỏa mãn các blogger.

Nếu ai từng lướt qua một blog được thiết kế bằng Wordpress thì có thể thấy kiểu phân trang khá chuẩn bằng 1 plugin có tên WP-PageNavi. Nếu tìm hiểu plugin này thì sẽ thấy phần mã CSS mặc định như sau:
/*
Default style for WP-PageNavi plugin
http://wordpress.org/extend/plugins/wp-pagenavi/
*/
.wp-pagenavi {
clear: both;
}
.wp-pagenavi a, .wp-pagenavi span {
text-decoration: none;
border: 1px solid #BFBFBF;
padding: 3px 5px;
margin: 2px;
}
.wp-pagenavi a:hover, .wp-pagenavi span.current {
border-color: #000;
}
.wp-pagenavi span.current {
font-weight: bold;
}
Chúng ta có thể điều chỉnh một chút từ phần CSS này để sử dụng cho Blogger.

Đăng nhập Blogger, vào Edit HTML. Chèn vào trước dòng ]]></b:skin> với đoạn mã bên dưới.
.pagenavi{clear:both;margin:10px auto;text-align:center;}
.pagenavi span {padding:3px;margin-right:5px;background:transparent;border:none;}
.pagenavi a {padding:3px;margin-right:5px;text-decoration: none;background:#747170;}
.pagenavi a:visited{color:#fff}
.pagenavi a:hover {background:#044697;color:#fff;text-decoration:none}
.pagenavi .current {font-weight:bold;color:#fff;background:#F87217;text-decoration: none;}
.pagenavi .pages {font-weight:bold;border:none;}
Bạn có thể điều chỉnh các thông số màu sắc để điều chỉnh cho phù hợp với Blog của mình.

Lưu Template rồi chọn Expand Widget Templates.

Tiếp theo là cài đặt javascript. Trong Template (dùng tổ hợp phím Ctrl + F) tìm đến các dòng mã:
<b:section class='main' id='main' showaddelement='no'>
<b:widget id='Blog1' locked='true' title='Blog Posts' type='Blog'>
..................
<b:includable id='main' var='top'>
..................
<div class='post-feeds'>
<b:loop values='data:posts' var='post'>
<b:if cond='data:post.allowComments'>
<b:if cond='data:post.feedLinks'>
<b:include data='post.feedLinks' name='feedLinksBody'/>
</b:if>
</b:if>
</b:loop>
</div>
</b:if>
</b:includable>
<b:includable id='feedLinksBody' var='links'>
<div class='feed-links'>
<data:feedLinksMsg/>
<b:loop values='data:links' var='f'>
<a class='feed-link' expr:href='data:f.url' expr:type='data:f.mimeType' target='_blank'><data:f.name/> (<data:f.feedType/>)</a>
</b:loop>
</div>
</b:includable>
<b:includable id='comments' var='post'>
…………………..
</b:widget>
</b:section>
Chèn trước dòng <b:includable id='feedLinksBody' var='links'>

bằng đoạn mã bên dưới.
<b:includable id='page-navi'>
<div class='pagenavi'>
<script type='text/javascript'>
var pageNaviConf = {
perPage: 7,
numPages: 9,
firstText: "First",
lastText: "Last",
nextText: "Next",
prevText: "Prev"
}
</script>
<script src='http://hacodeproject.googlecode.com/files/pagenavi_v2.min.js' type='text/javascript'/>
<div class='clear'/>
</div>
</b:includable>
Bạn có thể tải về file pagenavi_v2.min.js và upload lên hosting để sử dụng cho Blog của mình.

Tiếp đến, tìm đến dòng sau đây:

<!-- navigation -->
<b:include name='nextprev'/>

Thay thế nó bằng đoạn mã bên dưới:
<!-- navigation -->
<b:if cond='data:blog.pageType == "index"'>
<b:include name='page-navi'/>
<b:else/>
<b:if cond='data:blog.pageType == "archive"'>
<b:include name='page-navi'/>
</b:if>
</b:if>
<b:if cond='data:blog.pageType == "item"'>
<b:include name='nextprev'/>
</b:if>
Ý nghĩa của đoạn mã trên là hiển thị phân trang kiểu Wordpress ở các trang chủ, trang label và trang lưu trữ, còn các trang bài viết thì dùng kiểu phân trang mặc định của Blogger.

Bạn có thể điều chỉnh các tham số sau đây:

var pageNaviConf = {
perPage: 7,
numPages: 9,
firstText: "First",
lastText: "Last",
nextText: "Next",
prevText: "Prev"
}

trong đó:

- perPage: số bài viết hiển thị trong 1 trang
- numPages: số trang hiển thị
- firstText, lastText, nextText, prevText: tương ứng là các từ hiển thị cho các nút First, Last, Next, Prev

Nếu bạn gặp khó khăn trong việc cài đặt, xin vùi lòng để lại câu hỏi dưới đây.
More about

Tạo số đếm cho nhận xét trên Blogger

Người đăng: ngaybennhau on Chủ Nhật, 14 tháng 11, 2010

Thỉnh thoảng lướt qua một số blogpot bạn sẽ thấy các nhận xét của độc giả được đánh số từ 1 đến n số nhận xét cho bài viết. Có thể nhiều blogger không thích thủ thuật này song về một phương diện nào đó thì nó cũng giúp cho blogspot của bạn khác với các blog khác. Ngoài ra nó còn giúp độc giả tìm bất kỳ một nhận xét nào đó dễ dàng hơn.

Trước khi thực hiện thủ thuật này khi đăng nhập Dashboard ở mục Settings >> Comments bạn nên chọn chế độ Embedded below post.

Bước 1: Vào Design >> Edit HTML nhớ backup Template của bạn và chọn Expand Widget Templates.

Nhấn Ctrl + F tìm dòng code: <b:loop values='data:post.comments' var='comment'>

Thay nó bằng đoạn code sau đây:

<script type='text/javascript'>var CommentsCounter=0;</script>
<b:loop values='data:post.comments' var='comment'>
<div class='' expr:id='data:comment.id'>

Tiếp tục tìm dòng code: <data:commentPostedByMsg/>

Chèn bên dưới nó bằng đoạn code sau đây:
<span class='comment-number'>
<a expr:href='"#comment-" + data:comment.id' title='Comment Link'>
<script type='text/javascript'>
CommentsCounter=CommentsCounter+1;
document.write(CommentsCounter)
</script>
</a>
</span>
Kế đến kéo xuống dưới một chút sẽ thấy đoạn code:
<dd class='comment-footer'>
<span class='comment-timestamp'>
<a expr:href='data:comment.url' title='comment permalink'>
<data:comment.timestamp/>
</a>
<b:include data='comment' name='commentDeleteIcon'/>
</span>
</dd>
Thêm thẻ </div> vào sau đoạn code ở trên.

Bước 2: Thêm đoạn code CSS dưới đây vào trước thẻ ]]></b:skin>.
.comment-number {
float: right;
background: url(http://i40.tinypic.com/14tmp9e.jpg) no-repeat;
width:50px;
height:50px;
margin-right: 15px;
margin-top: -35px; /*comments-counter position*/
text-align: center;
font-family: 'Century Gothic','Lucida Grande',Arial,Helvetica,Sans-Serif;
font-size: 18px;
font-weight: bold;
}

/*since the numbers are actually links, we need to force the color properties*/

.comment-number a:link, .comment-number a:visited {
color: #445566 !important;
text-decoration: none !important;
}
.comment-number a:hover, .comment-number a:active {
color: #FF9933 !important;
text-decoration: none !important;
}
Bạn có thể thay hình nền cho số đếm nhận xét theo URL đánh dấu màu xanh. Nếu vị trí số đếm không cân xứng với hình nền thì bạn điều chỉnh thông số ở 2 dòng bên dưới.

margin-right: 15px;
margin-top: -35px;
More about

DFX Audio Enhancer v9.302 (All Versions)

Người đăng: ngaybennhau


Give your digital music files more vibrancy with DFX® Audio Enhancer! DFX enhances your music listening experience by improving the sound quality of MP3, Windows Media, Internet radio and other music files. With DFX you can transform the sound of your PC into that of an expensive stereo system placed in a perfectly designed listening environment. Renew stereo depth, boost your audio levels and produce a deep, rich bass sound.


Advanced DSP Sound Effects:

* Harmonic Fidelity Restoration.
Adding Fidelity to your audio eliminates the "muffled" sound that is an artifact of the data compression algorithms used in Internet audio formats. DFX compensates for this loss of high frequency fidelity by carefully regenerating the missing high frequency harmonics in the audio. This harmonic restoration is performed using patent-pending technology that carefully synthesizes high frequency harmonics to replace the harmonics lost during the encoding process.

* Ambience, Stereo Imaging.
Adding Ambience to your audio compensates for the lost or diminished stereo depth that is the result of closely located speakers, poor listening environments, and sonic losses due to data compression of Internet audio formats. DFX compensates for the reduced stereo imaging and depth of PC audio by carefully regenerating the ambience and stereo depth. This same ambience processing has been used by Grammy winning engineers of artists such as Alanis Morissette and Ella Fitzgerald.

* 3D Surround Sound.
Using the 3D Surround Sound component adds amazing depth and body to your audio, compensating for monitoring limitations and sonic losses due to data compression. With 3D Surround processing the sounds will surround you, virtually putting you inside the music! 3D Surround enhances the sound played on conventional 2-speaker systems and makes even small PC speaker systems sound larger and richer. It is also fully compatible with Surround Sound playback systems.

* HyperBass.
Using the HyperBass component adds deep, rich bass sound to your audio by compensating for the bass limitations of almost all PC-based audio systems and data-compressed audio formats. DFX does this by carefully regenerating the low frequency harmonics, thus increasing the perceived bass, but without exceeding the speakers physical limits, adding or changing speakers or amplifiers, and without increased power consumption. HyperBass greatly improves the bass performance of any sound system.

* Dynamic Gain Boosting.
Adding Dynamic Boost increases the perceived loudness of your audio while minimizing distortion levels, particularly when using Internet audio systems. By adding Dynamic Gain Boosting, your playback system will sound twice as loud without losing any punch on loud passages.
Typical PC-based multimedia playback systems and even home stereo playback systems suffer from limited dynamic range and headroom. Dynamic Boost compensates for this limited headroom by carefully processing the audio to increase the perceived loudness of the audio without altering the perceived dynamic range.







More about