


Introduction to C# Web Applications Classic Notes (Volume 2)
Read the settings in Web.config
Conn = new SqlConnection(ConfigurationSettings.AppSettings[“cnFriends.ConnectString”]);
<appSettings> <!-- User application and configured property settings go here.--> <!-- Example: <add key="settingName" value="settingValue"/> --> <add key="cnFriends.ConnectionString" value="data source=(local)\NetSdk;initial catalog=FriendsData;user id=sa" /> </appSettings>
Several namespaces
When using DataSet, use using system.Data.SqlClient
When When configuring Web.config, use using system.Configuration
This reminds me of when I was learning C language in my freshman year
bool visible btnSearch.Text = visible? “New Search” : “Search” ;
This is also pretty good
dsResult.tables[“Users”].rows.count Conver.Tonint32(ConfigurationSettings.AppSettings[“Cokuale.number”]);
Ruthless 1: Use Session to save the results and bind them
Session[“Search”] = dsResults; dsResults = (DataSet) Session[“Search”];
grdResults.DataBind();
In fact, Session, Application, etc. are stored in object type, so they must be displayed in the end. Type conversion type
By the way, use null to judge whether a string type value is obtained.
Quehen 2: Select rows from DataTable
DataRow[] rows = dsResults.Tables[“Users”].Select(filter); dsResults = dsResults.Clone(); foreach(DataRow row in rows) { dsResults.Tables[“Tables”].ImportRow(row); }
Get a control on the webForm
ImageButton img = (ImageButton)e.Item.FindControl(“Selectbutton”)
Jump:
Server.Transfer(“Caoxicao.aspx”);
Add js script (Attributes attribute) to the server control
imgShow.Attributes.Add(“onclick”,”document.getElementById(‘tbPrefs').style.display = ‘block';”);
Then (Style attribute),
img.Style.Add(“Cursor”,'Pointer');
Color related:
ColorConvert cv = new ColorConvert(); Color selected = Color.Empty; Selected = (olor)cv.ConvertFromString(White);
Add Cookie
Response.Cookies.Add(new HttpCookie(“backColor”,r))
My Favorite----User Control
Using FriendsReunion.Controls; Protectd override void Oninit(EventArgs e) { FriendsFooter _footer = (FriendsFooter)LoadControl(Request.ApplicationPath+”/Controls/ FriendsFooter.aspx”); SubHeader _subHeader = new SubHeader(); } Page.Contros.AddAt(0,_footer); Page.Contros.AddAt(0,_subHeader); base.OnInit(e); }
New Html Control Instance
HtmlGenericControl p = new HtmlGenericControl(“p”); p.Style.Add(“background-color”,bg);
Use this Classes can represent HTML server control tags that are not directly represented by .NET Framework classes, such as , ,
Return DataSet
Public DataSet Contact() { String sql = “@ Select * from … …”; DataSet requests = new DataSet(); New SqlDtaAdapter (sql,conn).Fill(requests); //return requests.GetXml(); Return requests; }
Receive: (when the return value is a data set in Xml format)
DataSet results = new DataSet(); Results.ReadXml(new StringReader(fi.ContactRequest(userid)));
When using WebService, just add the [WebMethod] attribute to the method!
If you add cache, then [WebMethod(CacheDurition=600)]
Instantiate WebService
FriendsService.FriendsInfo fi = new FriendsService.FriendsInfo(); String userid; Userid = fi.GetUserID(“…”);
Tips!
HyperLink reg = new HyperLink(); Reg.ToolTip = “… …”;
Checkout:
System.Web.Security.Forms.Authentication.SignOut(); Response.write (Request.ApplicaltionPath);
Trace debugging:
Trace.Write Trace.Warn
Exception:
1. Throws exception
Program exception throws
Throw new ***Exception(“…”);
2. Catch exceptions
It must be thrown from a try code block at the beginning. The try code block is used to place all codes that may throw exceptions.
Eg:
Try { … … } Catch(ArgumentNullExeption e) { … }
Unhandled exception web.config setting
<Custom Errors mode = “on” defaultRedriect = “customerror.aspx”; />
The above is the detailed content of Introduction to C# Web Applications Classic Notes (Volume 2). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to delete Xiaohongshu notes? Notes can be edited in the Xiaohongshu APP. Most users don’t know how to delete Xiaohongshu notes. Next, the editor brings users pictures and texts on how to delete Xiaohongshu notes. Tutorial, interested users come and take a look! Xiaohongshu usage tutorial How to delete Xiaohongshu notes 1. First open the Xiaohongshu APP and enter the main page, select [Me] in the lower right corner to enter the special area; 2. Then in the My area, click on the note page shown in the picture below , select the note you want to delete; 3. Enter the note page, click [three dots] in the upper right corner; 4. Finally, the function bar will expand at the bottom, click [Delete] to complete.

Notes deleted from Xiaohongshu cannot be recovered. As a knowledge sharing and shopping platform, Xiaohongshu provides users with the function of recording notes and collecting useful information. According to Xiaohongshu’s official statement, deleted notes cannot be recovered. The Xiaohongshu platform does not provide a dedicated note recovery function. This means that once a note is deleted in Xiaohongshu, whether it is accidentally deleted or for other reasons, it is generally impossible to retrieve the deleted content from the platform. If you encounter special circumstances, you can try to contact Xiaohongshu’s customer service team to see if they can help solve the problem.

As a Xiaohongshu user, we have all encountered the situation where published notes suddenly disappeared, which is undoubtedly confusing and worrying. In this case, what should we do? This article will focus on the topic of "What to do if the notes published by Xiaohongshu are missing" and give you a detailed answer. 1. What should I do if the notes published by Xiaohongshu are missing? First, don't panic. If you find that your notes are missing, staying calm is key and don't panic. This may be caused by platform system failure or operational errors. Checking release records is easy. Just open the Xiaohongshu App and click "Me" → "Publish" → "All Publications" to view your own publishing records. Here you can easily find previously published notes. 3.Repost. If found

Link AppleNotes on iPhone using the Add Link feature. Notes: You can only create links between Apple Notes on iPhone if you have iOS17 installed. Open the Notes app on your iPhone. Now, open the note where you want to add the link. You can also choose to create a new note. Click anywhere on the screen. This will show you a menu. Click the arrow on the right to see the "Add link" option. click it. Now you can type the name of the note or the web page URL. Then, click Done in the upper right corner and the added link will appear in the note. If you want to add a link to a word, just double-click the word to select it, select "Add Link" and press

How to add product links in notes in Xiaohongshu? In the Xiaohongshu app, users can not only browse various contents but also shop, so there is a lot of content about shopping recommendations and good product sharing in this app. If If you are an expert on this app, you can also share some shopping experiences, find merchants for cooperation, add links in notes, etc. Many people are willing to use this app for shopping, because it is not only convenient, but also has many Experts will make some recommendations. You can browse interesting content and see if there are any clothing products that suit you. Let’s take a look at how to add product links to notes! How to add product links to Xiaohongshu Notes Open the app on the desktop of your mobile phone. Click on the app homepage

As a lifestyle sharing platform, Xiaohongshu covers notes in various fields such as food, travel, and beauty. Many users want to share their notes on Xiaohongshu but don’t know how to do it. In this article, we will detail the process of posting notes on Xiaohongshu and explore how to block specific users on the platform. 1. How to publish notes tutorial on Xiaohongshu? 1. Register and log in: First, you need to download the Xiaohongshu APP on your mobile phone and complete the registration and login. It is very important to complete your personal information in the personal center. By uploading your avatar, filling in your nickname and personal introduction, you can make it easier for other users to understand your information, and also help them pay better attention to your notes. 3. Select the publishing channel: At the bottom of the homepage, click the "Send Notes" button and select the channel you want to publish.

In 2022, Apple added a new feature to the Notes app on iPhone and iPad that allows you to quickly scan printed or handwritten text and save it in a digital text format. Read on to learn how it works. On earlier versions of iOS and iPadOS, scanning text into Apple's Notes app required tapping the note's text field and then tapping the "Live Text" option in the pop-up menu. However, Apple is making it easier to digitize real-world notes in 2022. The following steps show you how to do this on a device running iOS 15.4 or iPadOS 15.4 and above. On your iPhone or iPad, open "

Most people write down everything, including recipes, birthdays, song lyrics, and more. on their iPhone’s Notes app. But many iPhone users reported that they deleted very important notes on their iPhone by mistake and now they are very nervous and frustrated. They don't know how to restore it on iPhone. We have done a lot of research on the matter and found two methods to recover deleted notes from iPhone. In this article, we will explain these two methods with which you can easily get back deleted notes. How to Recover Deleted Notes via Notes App Step 1: You should first launch the Notes app from the home screen on your iPhone. Step 2: Launch the Notes application
