jquery for user control (ASCX) Assignment and Interface Application _ Practical skills

Source: Internet
Author: User

In this demo, the interface (interface) is used to dynamically load the user control on the Web page, and jquery is used to pass the values processed by the Web page to the user control.

In programming, it is preferred to use an interface that can handle the same behavior for different objects.

Copy Code code as follows:

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;

<summary>
Summary description for Isetvalable
</summary>
Namespace Insus.net
{
public interface Isetvalable
{
void SetValue (string value);
}
}

The above interface is to assign a value to a control after it has been implemented.

Next, we create a user control, where the user control's ascx places a label label that will be used to display the values passed from the page. In a real environment, it may not be a simple label control, but another control, or an object.

Copy Code code as follows:

<%@ control language= "C #" autoeventwireup= "true" codefile= "InsusUc.ascx.cs" inherits= "Insusuc"%>
<asp:label id= "labelmessage" runat= "Server" text= "" ></asp:Label>

Within the Ascx.cs code, the interface needs to be implemented to assign the parameters of the method implemented by the interface to the label's text.
Copy Code code as follows:

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using Insus.net;

public partial class Insusuc:system.web.ui.usercontrol,isetvalable
{
protected void Page_Load (object sender, EventArgs e)
{

}
public void SetValue (string value)
{
This. labelMessage.Text = value;
}
}

OK, the interface is created with the user control and you need to create a Web page. Write a Web methods method in. aspx.cs:

. aspx:

Animation Demo:

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.