asp+ Chinese Tutorial (ii)--asp+ Web Forms

Source: Internet
Author: User
Tags button type html form
asp+|web| Tutorials | Chinese two, ASP + Web Forms

ASP + Web Forms, a Microsoft term, according to its own words, the ASP + Web Forms page framework is an upgradeable NGWS runtime programming model that dynamically generates Web pages on the server. Not too understood, actually, just like the HTML form, but it can be dynamically changed on the server side, and not like static HTML form as soon as the generation can not be changed, of course, with DHTML or remote script will also be able to do dynamic change, but after all, is not very convenient. So what is Web forms like? You've already met, remember the last time I gave that example, yes, that's a Web form, but since that example is full of static HTML, when you press the "Lookup" button, it's just a presentation, nothing happens, Now let's look at a truly web Forms that comes with an ad rotation control, a text entry box, a selection box, a button, and a text label, as follows.

File:Intro6.aspx

<link rel= "stylesheet" href= "Intro.css" >

<script language= "C #" runat=server>

void SubmitBtn_Click (Object sender, EventArgs e) {
Message.Text = "Hi" + Name.text + ", you selected:" + Category.selecteditem;
}

</script>

<body>

<center>

<form action= "intro6.aspx" method= "POST" runat= "Server" >

<asp:adrotator advertisementfile= "Ads.xml" bordercolor= "Black" borderwidth=1 runat= "Server"/>


Category: <asp:dropdownlist id= "Category" runat=server>
<asp:listitem>psychology</asp:listitem>
<asp:listitem>business</asp:listitem>
<asp:listitem>popular_comp</asp:listitem>
</asp:dropdownlist>

<asp:button type=submit text= "Lookup" onclick= "SubmitBtn_Click" runat= "Server"/>

<p>

<asp:label id= "message" runat= "Server"/>

</form>

</center>

</body>

OK, now let's take a concrete look at this asp+ program and ASP in the end what is different, first you may notice that the original ASP <%%> script delimiter disappeared, replaced by <script Language=...> Originally I most hate is this <%%>, especially in the HTML mixed use of time, it is not like a programming language, you have to see from such a program process flow, it is more difficult than heaven, now good. Of course this is not to say that you can not use <%%&gt, after all, it is forward compatible with ASP, but I still try to use as little as possible. Look at the following paragraph:
<script language= "C #" runat=server>

void SubmitBtn_Click (Object sender, EventArgs e) {
Message.Text = "Hi" + Name.text + ", you selected:" + Category.selecteditem;
}

</script>

Do you feel familiar with friends who have used C? Yes, this is an event handler written in C #, void SubmitBtn_Click (Object sender, EventArgs e), you might see it, void means that the function has no return value, the function has two parameters, the code has only one line, You may notice that the message, Name, and category in this line of code are not defined, so where do they come from? Look at the following code:
<form action= "intro6.aspx" method= "POST" runat= "Server" >

<asp:adrotator advertisementfile= "Ads.xml" bordercolor= "Black" borderwidth=1 runat= "Server"/>


Category: <asp:dropdownlist id= "Category" runat=server>
<asp:listitem>psychology</asp:listitem>
<asp:listitem>business</asp:listitem>
<asp:listitem>popular_comp</asp:listitem>
</asp:dropdownlist>

<asp:button type=submit text= "Lookup" onclick= "SubmitBtn_Click" runat= "Server"/>

<p>

<asp:label id= "message" runat= "Server"/>

</form>

Is this form completely different from the HTML form? First, all of the form items include the form itself followed by the runat=server, which means that this is the server-side control, as well as the traditional form of what <input type=text>, and so on, you look closely can see, The original text box becomes <asp:textbox&gt, the selection box changes to <asp:dropdownlist>, the selection box option changes to <asp:listitem&gt, and the submit button changes to <asp: Button&gt, this button corresponds to the control function of the SubmitBtn_Click function I mentioned just now, it is running on the server side. There is also a server-side control <asp:label id= "message" runat= "Server"/&gt, this asp:label is not the traditional form, it is a server-side text control, then there is a problem, if

[1] [2] Next page



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.