分享
 
 
 

ASPDotNet

王朝asp·作者佚名  2008-05-18
窄屏简体版  字體: |||超大  

This little block can be used to print all Request[*]:

foreach(string item in Request.Params)

{

Response.Write(item + " = " + Request[item]);

Response.Write("<br>");

}

And this one can be used to encode a URL (RFC1738):

HttpUtility.UrlEncode("APP=WebFS&Conf=vitals.rcf"); // output is APP%3dWebFS%26Conf%3dvitals.rcf

You have created a Web application called ProjectName with VS.Net 2003 and now you want to check it in. How do you do that?

When you are moving a project, make sure to copy the folder and not just the content from "C:\inetpub\wwwroot\ProjectName". The reason is that there are some permissions here that must be copied, too. Otherwise, you will get an error message "Failed to Start Monitoring Directory Changes", KB317955. Anyway, here are the full steps:

1) Stop IIS.

2) Go to "C:\inetpub\wwwroot\ProjectName" and copy (not move) it to someplace else. Locate ProjectName.sln in "C:\Documents and Settings\My Documents\Visual Studio Projects\ProjectName" and copy that, too. If you want to rename the project, this is the chance:

a) Open the following three files and do a global search and replace to rename ProjectName to something else: Global.asax, ProjectName.csproj, ProjectName.csproj.webinfo, and ProjectName.sln

b) Rename ProjectName.csproj, ProjectName.csproj.webinfo, and ProjectName.sln to, say, NewProjectName.

3) Delete the virtual directory from IIS. This will also delete the physical directory and files.

4) Go to the copy, and remove the following dirs: _vti_cnf, _vti_pvt, _vti_script, _vti_txt, and bin.

5) Check-in ProjectName and its content first.

6) Start IIS.

7) Recreate the virtual directory, but this time point it to the new location.

9) Open ProjectName.sln or ProjectName.csproj (if you don't have ProjectName.sln). Rebuild it to be sure everything is working.

10) Test it by pressing Ctrl+F5 or by going to http://localhost/ProjectName/MainForm.aspx (where MainForm.aspx is your main form).

PS. If you don't have ProjectName.sln, you can still proceed by doing an Open Project From Web, save that, and move ProjectName.sln to the same location as the ProjectName.csproj.

creating controls dynamically; error with "controls" must be inside a form bla bla bla

how to popup a window on the browser side asking for confirmation

how to check a box in a CheckBoxList

how to force a PostBack? set AutoPostBack attribute to true

how to get the request parameters? through Request["paramname"]

how do I run an sql query and mix the resulting records with my own columns (say clickable buttons)?

working with HashTable, working with HttpRequest?

check for mobile device? if (Request.Browser["IsMobileDevice"] == "true" ) {

Response.Redirect(Request.ApplicationPath); // Redirect to caller

Response.Redirect(Request.RawUrl); // Redirect to the same page to pick up changes

Web Service method seems to be limited to only one array (eg. string[]) in its out parameter. Could apply also to other data types. Put more than that, and weird things happen like the ordering of the parameter on the proxy is not the same as the one in the actual implementation.

How to get a DataSet to write an xml string and read an xml string into a DataSet?

string connection = "Server=pc-se-kuncoro;Database=mdpp;User ID=kuncoro;Password=kuncoro";

string query = "select * from patients";

DataSet dataset = SqlHelper.ExecuteDataset(connection, CommandType.Text, query);

DataGrid1.DataSource = dataset;

DataGrid1.DataBind();

System.IO.StringWriter sw = new System.IO.StringWriter();

dataset.WriteXml(sw, XmlWriteMode.WriteSchema);

System.IO.StringReader sr = new System.IO.StringReader(sw.ToString());

DataSet dataset2 = new DataSet();

dataset2.ReadXml(sr, XmlReadMode.ReadSchema);

DataGrid2.DataSource = dataset2;

DataGrid2.DataBind();

CHAPTER 1

complex data bind: list controls (DropDownList, CheckBoxList, RadioButtonList, ListBox)

and iterative controls (Repeater, DataList, and DataGrid); they all take data sources,

but iterative controls can apply HTML templates to its rows

split can be used to split Request["blabla"] into several segments

Color.White

Color.FromName("white")

Color.FromName("#00ee00")

DataList control provides special support for five predefined command names: edit, update, delete, cancel, and select. (p.22)

Clicking on a button with one of the above names will generate two events: ItemCommand and xxxCommand.

int employeeID = DataKeys[DataList1.SelectedIndex]; (p.23)

CHAPTER 2

???

CHAPTER 3

Two choices of column, BoundColumn (no customization) and TemplateColumn (allows customization).

TemplateColumn's possible types: ItemTemplate, EditItemTemplate, HeaderTemplate, and FooterTemplate.

Check out p.79 for a good example on concatenating data fields for TemplateColumn.

There is a trick on p.82 that allows grouping more than one column in a single column header.

ItemCreated event handler is a good place to modify whatever DataGrid has prepared for an item (a row).

Check the tip on p.83 to provide spacing and padding for every cell in a DataGrid.

Can I apply a template for column headers and have a sort ability, too? To a certain degree, p.86.

Loading templates dynamically at runtime? Put the template in an ascx file.

Use FindControl (p.92) to find a control that is not accessible at the page level due to teh implementation of ASP.NET templates.

If you change a template for a column at runtime, you need to refresh the view (p.93).

Loading a template from a temp. file? make sure you use something like a Session ID or Path.GetTempFileName to create the file (p.93).

Want to replace the work that ASP.NET when parsing a template? Do it yourself by inheriting from ITemplate (p.94).

A nice example of customizing a column to show images instead of text, p.99.

Wanna have a cell that is actually a DropDownList (or any other control)? Check the hint at p.101.

CHAPTER 7

DataSet is an in-memory cache of data and is passed between the middle tier and the client application.

DataGrid does not cache the DataSet it is bound to. There are two ways to tackle this issue: use DataReader with custom pagination, or cache it in the Cache object (p.213-214).

Unlike the Session object, the Cache object does not work on a per-user basis. Still Cache object gives good performance.

XmlTextReader (reads an XML file) and SqlDataAdapter (query SQL Server), both can be used to fill a DataSet.

In .NET, shallow copying can be performed with MemberwiseClone. For deep copying, a Clone method must be implemented since the default behavior simply does shallow copying (p.218).

For rows, you can either use the Rows property and DataRowCollection, or ImportRow (p.218-219).

The last piece to know is Batch Update, the process in which changes made to the DataSet is persisted to the actual database. Potential problem: conflicts due to updates being done from the time you get your DataSet and the time you commit your DataSet.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有