小新二三事 二三事 電視精/戲院 ASP .NET 新手工作日誌
顯示包含「ASP 新手」標籤的文章。顯示所有文章
顯示包含「ASP 新手」標籤的文章。顯示所有文章

2009年9月13日星期日

ASP.NET Warning: 具有潛在危險 Request.Form 的值已從用戶端偵測到 (2)

ASP.NET Warning: 具有潛在危險 Request.Form 的值已從用戶端偵測到 (2)

又中
http://hk-siusun.blogspot.com/2009/07/aspnet-warning-requestform.html

ASP.NET Code: Building Mobile Web Pages in ASP.NET 3.5 Tutorial

ASP.NET Code: Building Mobile Web Pages in ASP.NET 3.5 Tutorial

Build a mobile web page. Use the mobile device emulator to test it. View and update databases from a handheld. Using Visual Studio 2008 and ASP.NET 3.5.



Northwind and pubs Sample Databases
http://www.microsoft.com/Downloads/details.aspx?FamilyID=06616212-0356-46a0-8da2-eebc53a68034&displaylang=en

2009年9月12日星期六

ASP.NET Code: 用 RoleGroups 分唔同 LoginView

ASP.NET Code: 用 RoleGroups 分唔同 LoginView

ASP.Net 2.0 LoginView Control
LoginView provides the functionality to create different views for the users of different Roles. LoginView control consists of 3 different templates:
1. AnonymousTemplate
2. LoggedInTemplate
3. RoleGroups
http://programming.top54u.com/post/ASP-Net-2-0-LoginView-Control.aspx

18.4 ASP.NET 2.0的授權
處理了要訪問Web應用程序的用戶的註冊和身份驗證之後,下一步就是授權。用戶可以查看什麼內容?要承擔什麼角色?這些對於任何Web應用程序來說都是很重要的問題。下面首先學習如何給驗證用戶顯示某些內容,給未驗證用戶顯示另外一些內容。
http://book.csdn.net/bookfiles/469/10046916564.shtml

2009年8月26日星期三

ASP.Net Code: Connection Strings with MS SQL server 2005

ASP.Net Code: Connection Strings with MS SQL server 2005

<remove name="LocalSqlServer">
<add name="LocalSqlServer" connectionstring="Data Source=localhost;Initial Catalog=aspnetdb;Integrated Security=True" providername="System.Data.SqlClient">
<add name="golddbConnectionString" connectionstring="Data Source=localhost;Initial Catalog=golddb;Integrated Security=True" providername="System.Data.SqlClient">

+

exec sp_grantloginaccess 'NT AUTHORITY\NETWORK SERVICE'
exce sp_addsrvrolemember @loginame = 'NT AUTHORITY\NETWORK SERVICE', @rolename = 'sysadmin'

工作日誌: load DB, Asp.net 入 MS SQL 2005 Server

工作日誌: load DB, Asp.net 入 MS SQL 2005 Server

1. load SQL 入 MS SQL 2005 Server
2. set 唔到 Connection Strings
3. 唯有安Visual Web Developer 2008 Express
4. 都係 set 唔到 Connection Strings
跟 http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx
得左

Connection Strings 要 set LocalSqlServer
先見到 ASP.NET config

5. Asp.net 個web 係VWD ok, 出到 IIS 唔得
6. MS SQL 2005 Server access right problem
Connection Strings 無password

原來要係SSMS

exec sp_grantloginaccess 'NT AUTHORITY\NETWORK SERVICE'
exce sp_addsrvrolemember @loginame = 'NT AUTHORITY\NETWORK SERVICE', @rolename = 'sysadmin'

中文
http://www.cnblogs.com/windphoenix/archive/2008/11/03/1325321.html
英文
http://forums.asp.net/p/905865/1836699.aspx
http://social.msdn.microsoft.com/forums/en-US/adodotnetdataproviders/thread/26fd5295-e9e2-44e7-9a3d-6af69da77093/
http://stackoverflow.com/questions/764494/no-admin-rights-in-sql-management-studio

7. web ok la...
8. Asp.net 個網 access right problem
set 番 IIS 個right -> 唔得
set 番 folder 個right -> 終於得

set 完個頭出晒煙

2009年8月18日星期二

ASP.NET Code: HOW TO: Send email using System.Net.Mail 2

ASP.NET Code: HOW TO: Send email using System.Net.Mail 2

After set SMTP host, username, password in web.config

SmtpClient smtp = new SmtpClient();
smtp.Send(msg);

more at
http://blog.miniasp.com/?tag=/smtpclient

2009年8月12日星期三

2009年8月11日星期二

ASP.NET Code: copy file and folder recursively

ASP.NET Code: copy file and folder recursively

Private Sub CopyDirectory(ByVal sourcePath As String, ByVal destPath As String, ByVal overwrite As Boolean)
Dim sourceDir As System.IO.DirectoryInfo = New System.IO.DirectoryInfo(sourcePath)
Dim destDir As System.IO.DirectoryInfo = New System.IO.DirectoryInfo(destPath)
'the source directory must exist for our code to run
If (sourceDir.Exists) Then
'if the destination folder does not exist, create it
If Not (destDir.Exists) Then
destDir.Create()
End If
'loop through all the files of the current directory
'and copy them if overwrite=true or they do not exist
Dim file As System.IO.FileInfo
For Each file In sourceDir.GetFiles()
If (overwrite) Then
file.CopyTo(System.IO.Path.Combine(destDir.FullName, file.Name), True)
Else
If ((System.IO.File.Exists(System.IO.Path.Combine(destDir.FullName, file.Name))) = False) Then
file.CopyTo(System.IO.Path.Combine(destDir.FullName, file.Name), False)
End If
End If
Next
'loop through all the subfolders and call this method recursively
Dim dir As System.IO.DirectoryInfo
For Each dir In sourceDir.GetDirectories()
If (dir.FullName <> Server.MapPath(strDestinationDir)) Then
CopyDirectory(dir.FullName, System.IO.Path.Combine(destDir.FullName, dir.Name), overwrite)
End If
Next
lblStatusMessage.Text = "Folder copied successfully"
lblStatusMessage.Visible = True
'if source directory does not exist
Else
lblStatusMessage.Text = "Error: source folder does not exist!"
lblStatusMessage.Visible = True
End If
End Sub

code from
http://www.xefteri.com/articles/show.cfm?id=16

good example

ASP.NET Code: get website url path

ASP.NET Code: get website url path

Dim str_server As String
Dim sArr As String()
Dim str_region As String
Dim str_lang As String

str_server = Request.Path.Substring(0, Request.Path.LastIndexOf("/") + 1)
sArr = Split(str_server, "/")
str_region = sArr(2)
str_lang = sArr(3)

2009年7月24日星期五

ASP.NET Code: Export Excel from Gridview Data

ASP.NET Code: Export Excel from Gridview Data

如何將GridView的內容匯出成Excel?
http://blog.blueshop.com.tw/lolota/archive/2007/02/25/49703.aspx

Add Code
GridView1.AllowSorting = False
GridView1.AllowPaging = False
GridView1.DataBind()
before
GridView1.RenderControl(hw)

ASP.NET Code: HOW TO: Send email using System.Net.Mail

ASP.NET Code: HOW TO: Send email using System.Net.Mail

Send Email using Gmail ASP.NET C# VB.NET
http://csharpdotnetfreak.blogspot.com/2009/06/aspnet-send-email-using-gmail.html
using username and password in code

Sending Email with System.Net.Mail
http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx
using SMTP setting in web.config

ASP.NET內抓取網址的方式一覽表(Request)
http://demo.tc/view.aspx?id=230
Request.Url.Query[id]

http://digitalcolony.com/2007/08/sending-email-in-aspnet-using-smtp.aspx
http://www.jscape.com/articles/sending_email_using_vb.html

2009年7月18日星期六

ASP.NET Code: MasterPage.master Concept

ASP.NET Code: MasterPage.master Concept

MasterPage.master Concept

http://www.packtpub.com/article/asp.net-3.5-cms-adding-security-and-membership-part1

http://blog.xuite.net/jayhunglai/Jblog/245379

How to add MasterPage to existing page?

http://forums.asp.net/p/881332/910714.aspx

ASP.NET Code: /admin Acces Right

ASP.NET Code: /admin Acces Right

ASP.NET Web 應用程式管理員
安全性
存取規則
建立存取規則

會生一個 Web.config 係 /admin


<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<authorization>
<allow users="admin" />
<deny users="?" />
<deny users="*" />
</authorization>
</system.web>
</configuration>


http://www.packtpub.com/article/asp.net-3.5-cms-adding-security-and-membership-part1

http://www.packtpub.com/article/asp.net-3.5-cms-adding-security-and-membership-part2

2009年7月17日星期五

ASP.NET Code: www.qsh.eu ASPNETDB.MDF

ASP.NET Code: www.qsh.eu ASPNETDB.MDF


<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;Database=www.qsh.eu_8a547bfd-ce62-405a-bbfe-1628ac48aa15;AttachDBFilename=|DataDirectory|ASPNETDB.MDF" />
</connectionStrings>


http://forum.qsh.eu/Forums.aspx?forumid=25&threadid=79

http://forum.qsh.eu/Forums.aspx?searchtext=aspnet

http://www.cnblogs.com/hardrock/archive/2007/11/13/958546.html

ASP.NET Code: www.qsh.eu ConnectionString

ASP.NET Code: www.qsh.eu ConnectionString
For examle you have database "Test.mdf" created at SQL Server Management Studio Express.

1st step: your database must be detached from your SQL server correctly: open management studio -> right click on "Test" database -> Tasks -> Detach.

2nd step: create folder www/App_Data and copy Test.mdf without log file.

3 step: generate connection string at https://www.qsh.eu/admin/EditFreehosting.aspx and save in web.config.

4 step: replace name="LocalSqlServer" with (for example) name="DBAccess".

5 step: in code you can read connection string from web.config:

string connectionString = ConfigurationManager.ConnectionStrings["DBAccess"].ConnectionString;
IDbConnection connection = new SqlConnection(connectionString);
OR
replace name="DBAccess" with (for example) name="LocalSqlServer" in all ASPX
the stupid method i did once...

Login Link for www.qsh.eu
https://www.qsh.eu/admin/Login.aspx

免費asp.net空間(www.qsh.eu)使用詳解
http://www.0379zd.com/news/show/17001.htm

Qantasoft qsh.eu webconfig connectionString problem
http://forums.asp.net/p/1253493/2356606.aspx#2356606

2009年7月14日星期二

ASP.NET Code: SqlConnection with ConnectionString

ASP.NET Code: SqlConnection with ConnectionString
Dim SQLData As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\db.mdf;Integrated Security=True;User Instance=True")
Dim SQLData As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("
dbConnectionString
").ConnectionString)
from
http://www.aspnet101.com/aspnet101/tutorials.aspx?id=64

2009年7月11日星期六

ASP.NET Step: Move / Export Database from Microsoft SQL Server 2008 to mdf File

ASP.NET Step: Move / Export Database from Microsoft SQL Server 2008 to mdf File

1. Download SQL Server Management Studio
from VWD website

2. Read the followings doc
http://www.windows-tech.info/15/206f0457374acafb.php

3. Follow Steps in
How to: Detach a Database (SQL Server Management Studio)
http://msdn.microsoft.com/en-us/library/ms191491.aspx

4. Copy the mdf to VWD website's App_Data Folder
from
C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA

5. Open Web.config
Replace the connection String as we detached the database from server
and run it as standalone file

<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\db.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />

ASP.NET Warning: 具有潛在危險 Request.Form 的值已從用戶端偵測到

ASP.NET Warning: 具有潛在危險 Request.Form 的值已從用戶端偵測到

具有潛在危險 Request.Form 的值已從用戶端偵測到

若是出現這樣的錯誤訊息,代表頁面上有文字內容是包含Html這類的語法,通常在使用一些Html的編輯器(留言板、討論區之類常用)做資料送出的動作的時候會發生。

解決辦法如下:

在頁面的Page指示語加入 validateRequest="false"


http://blog.blueshop.com.tw/greenwings/archive/2007/02/22/49690.aspx

ASP.NET Warning: 並未將物件參考設定為物件的執行個體

ASP.NET Warning: 並未將物件參考設定為物件的執行個體

System.NullReferenceException:
並未將物件參考設定為物件的執行個體

通常...這種錯誤就是
"使用了某種物件, 但卻未宣告"
朝這個方向去找吧, 仔細檢查一下程式裡面有沒有哪裡有這樣的情形
該用new 沒有new

如果用的是vs.net2003...
那這個錯誤下中斷點,瞬間就能找出

2009年7月10日星期五

ASP.NET Code: SQL SELECT command based on DropDownList

ASP.NET Code: SQL SELECT command based on DropDownList

SQL SELECT command based on DropDownList

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:dbConnectionString %>"
SelectCommand="SELECT * FROM [menu] WHERE (([region] = @region) AND ([lang] = @lang)) ORDER BY [menuId]"
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="region"
PropertyName="SelectedValue" Type="String" />
<asp:Parameter DefaultValue="1" Name="lang" Type="String" />
</SelectParameters>