Asp.net's confusion about using radiobuttonlist-using the keyword new to create an instance

Source: Internet
Author: User
After a day of hard work, I am exhausted. Paste it here for help. Save your life!
Page: <body>
<Form ID = "form1" runat = "server">
<Div>
<Asp: radiobuttonlist id = "radiobuttonlist1" runat = "server">
</ASP: radiobuttonlist> </div>
<Asp: button id = "button1" runat = "server" onclick = "button#click" text = "button"/>
</Form>
</Body>
</Html>

CS part of solution 1: protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
This. radiobuttonlist1.items. Add (New listitem ("test1", "test1 "));
This. radiobuttonlist1.items. Add (New listitem ("Test2", "Test2 "));
}
}
Protected void button#click (Object sender, eventargs E)
{
Response. Write (this. radiobuttonlist1.selecteditem. value );
}

CS Part II: protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
This. radiobuttonlist1.items. Add (New listitem ("test1", "test1 "));
This. radiobuttonlist1.items. Add (New listitem ("Test2", "Test2 "));
}
}
Protected void button#click (Object sender, eventargs E)
{
Radiobuttonlist RBL = new radiobuttonlist ();
RBL = (radiobuttonlist) page. findcontrol ("radiobuttonlist1 ");
Response. Write (RBL. selecteditem. value );
}

An endless attempt was made to create an instance using the keyword "Please use the new keyword". It was speechless and the experts passed by. Please take the time to help your younger brother. Now the communist society is ready, should it always be communist?

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.