ITPub博客

首页 > 应用开发 > IT综合 > ASPDotNet(转)

ASPDotNet(转)

原创 IT综合 作者:post0 时间:2007-08-24 17:07:20 0 删除 编辑
ASPDotNet(转)[@more@]

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

  foreach(string item in Request.Params)

  {

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

  Response.Write("
");

  }

  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:inetpubwwwrootProjectName". 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:inetpubwwwrootProjectName" and copy (not move) it to someplace else. Locate ProjectName.sln in "C:Documents and SettingsMy DocumentsVisual Studio ProjectsProjectName" 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

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8225414/viewspace-965581/,如需转载,请注明出处,否则将追究法律责任。

下一篇: PythonTips(转)
请登录后发表评论 登录
全部评论
  • 博文量
    2031
  • 访问量
    7926617