[Self-study Notes] ASP. NET tips

Source: Internet
Author: User

1. Change the text on the button

First look at the effect:

1,

2,

3,

One button and one label Control

Code:

Think about it again

Protected   Void Button#click ( Object Sender, eventargs E)
{
// Object sender, the object that triggers this event
// E is the parameter that may be passed when this event is triggered.
// Change the dynamic display text of the button
If (Button1.text =   " Show Details " )
{
Button1.text =   " Hide " ;
Label1.text =   " This shows the detailed information: <br/> name: A 1 <br/> Gender: male " ;
}
Else
{
Button1.text =   " Show Details " ;
Label1.text =   " This is a hidden state! " ;
}

 

Ii. Use Image to control the production of simple ad Rotation

Code

Code

// Definition range: 0-10
Random random =   New Random ();
Int Rannum = Random. Next ( 10 );

If(Rannum< 5)
Linkimage. imageurl=Ima1.gif;
Else
Linkimage. imageurl=Ima2.gif;

 

3. browser Detection

 

Browser Detection

  Protected   Void Button2_click ( Object Sender, eventargs E)
{
Httpbrowsercapabilities Browser = Request. browser;
String Str =   " Type: "   + Browser. Type +   " <Br/> "
+   " Name: "   + Browser. Browser +   " <Br/> "
+   " Version: "   + Browser. Version +   " <Br/> "
+   " Platform: "   + Browser. Platform;
This . Label2.text = STR; // On the aspx page, you can set its title from the post code because it has runat = server statements.
This. Page. header. Title = "browser detection ";
}

 

 

It's very simple and there's no technology at all. Don't laugh!

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.