Use webpart series controls in ASP. NET 2.0 (2)

Source: Internet
Author: User
Next, we will introduce how to use custom controls in the webpart control series.

1. First, we add a "Google. ascx" Control for the project, and add the famous Google logo image under the images directory.

Next, add a 2*2 row table to the form, set it to google.gif, and add a text box and a button, as shown in. The name of the control is in the brackets:



3. Write the following in the Click Event of the btnsearch button: Code :

Response. Write (page. isvalid)
Dim querystr as string = httputility. urlencode (txtsearch. Text)
Response. Redirect ("http://www.google.com/search? Q = "& querystr)
End sub

4. Drag the compiled Google. ascx control to the cell in the middle of the table we just created, as shown in:



Modify the Code as follows:

<Uc1: Google Title = "Google Search" runat = "server" id = "google1"/>

Next, run F5. You can see that Google search is performed in the webpart of googlesearch.

At the same time, if you think that the buttons for webpart close, restore, and minimize are not very nice, you can also customize the buttons, such as adding the following image under the images directory:



Then, you can specify the following attributes in the attributes of webpartzone1.

Closeverb. imageurl = "images/closeverb.gif"
Editverb. imageurl = "images/editverb.gif"
Minimizeverb. imageurl = "images/minimizeverb.gif"
Restoreverb. imageurl = "images/restoreverb.gif"

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.