您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

c#用户控件

2024/2/26 6:33:21发布21次查看
前台: %@ control language=c# autoeventwireup=true codefile=chenlogin.ascx.cs inherits=chenlogin % asp:textbox id=textbox1 runat=server/asp:textbox asp:button id=button1 runat=server onclick=button1_click text=button /
前台:
function winpup()
    {
        if ( document.getelementbyid('').value == )
        {
            alert(不能为空!);
            return false;
        }
        else
        {
            alert(chen);
            return true;
        }
    }
后台:
using system;
using system.data;
using system.configuration;
using system.collections;
using system.web;
using system.web.security;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.webcontrols.webparts;
using system.web.ui.htmlcontrols;
using system.data.sqlclient;
using system.componentmodel;
public partial class chenlogin : system.web.ui.usercontrol
{
    private string txtname = ;
    private string reuri = ;
    private string datasource = ;
    private string lbltext = 请填写。;
public string txtname
    {
        get
        {
            return this.textbox1.text.trim();
        }
    }
public string reuri
    {
        set
        {
            reuri = value;
        }
    }
public string datasources
    {
        set
        {
            datasource = value;
        }
    }
//[category(demo), description(demo from idothink.com)]
    public string lbltext
    {
        get
        {
            return lbltext;
        }
        set
        {
            lbltext = value;
            this.invalidate();
        }
    }
private void invalidate()
    {
        this.label1.text = lbltext;
    }
protected void page_load(object sender, eventargs e)
    {
        if (!ispostback)
        {
            button1.attributes.add(onclick, return winpup(););
            button1.attributes.add(style, border:1px solid #f00;color:#f00;);
        }
    }
//protected override void onpaint(painteventargs pe)
    //{
    //    // calling the base class onpaint
    //    base.onpaint(pe);
//    // custom paint code here
    //    pe.graphics.drawstring(
    //    hellovalue,
    //    font,
    //    new solidbrush(forecolor),
    //    clientrectangle, new stringformat());
    //}
protected void button1_click(object sender, eventargs e)
    {
        //response.redirect(reuri);
        this.label1.text = this.textbox1.text;
    }
}
如何引用用户控件请查看:
http://blog.csdn.net/ajaxchen_615/archive/2009/05/22/4208247.aspx
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product