用户控件

前台页面:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="EnterpriseInfoControl.ascx.cs"
    Inherits="UserControls_EnterpriseInfoControl" %>
<input type="hidden" id="TxtOrganId" name="TxtOrganId" runat="server" />
<input type="hidden" id="TxtIsDepartment" name="TxtIsDepartment" runat="server" />
<input id="TxtOrganName" type="text" name="TxtOrganName" style="width: 60%;" runat="server" />
<input class="button2" id="BtnOrganId" runat="server" type="button" value="选择" />
<input type="button" id="BtnClear" value="清除" onclick="ClearOrgan()" class="button2"
    runat="server" />

 

后台页面:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using HHH.Jcjg_HBS.Common;

public partial class UserControls_EnterpriseInfoControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string script = "<script language='javascript' type='text/javascript'> function ClearOrgan() {  document.getElementById('" + TxtOrganName.ClientID + "').value=''; document.getElementById('" + TxtOrganId.ClientID + "').value='';}</script>";
        Page.ClientScript.RegisterStartupScript(typeof(string), "ClearOrgan", script);

        string showDialog = string.Format("javascript:return ShowHiddenDialogs('{0}','{1}','{2}?isDepartment={3}&time={4}&AreaType={5}&IsALog={6}',500,450);", TxtOrganName.ClientID, TxtOrganId.ClientID, StaticDatas.EnterpriseInfo, IsDepartment, DateTime.Now.ToString(), MyCommon.GetInstance().GetAreaType(), IsALog);
        BtnOrganId.Attributes.Add("onclick", showDialog);
    }

    public string TextBoxWidth
    {
        set { TxtOrganName.Style.Add("width", value); }
    }


    public string Value
    {
        get
        {
            if (!string.IsNullOrEmpty(TxtOrganName.Value.Trim()) && !string.IsNullOrEmpty(TxtOrganId.Value.Trim()))
            {
                return TxtOrganId.Value.Trim();
            }
            return "";
        }
        set
        {
            TxtOrganId.Value = value;
        }
    }

    public string Text
    {
        get
        {
            if (!string.IsNullOrEmpty(TxtOrganName.Value.Trim()))
            {
                return TxtOrganName.Value.Trim();
            }
            return "";
        }
        set
        {
            TxtOrganName.Value = value;
        }
    }

 

    public string IsDepartment//0true 1false
    {
        get
        {
            if (!string.IsNullOrEmpty(TxtIsDepartment.Value.Trim()) && !string.IsNullOrEmpty(TxtIsDepartment.Value.Trim()))
            {
                return TxtIsDepartment.Value.Trim();
            }
            return "";
        }
        set
        {
            TxtIsDepartment.Value = value;
        }
    }

    private string mIsLog = "0";
    public string IsALog
    {
        get
        {
            return mIsLog;
        }
        set
        {
            mIsLog = value;
        }
    }

    public bool isReadonly
    {
        set
        {
            if (!value)
            {
                TxtOrganName.Attributes.Add("readonly", "readonly");
            }
        }
    }
}

posted on 2013-04-22 19:31  dengjd  阅读(119)  评论(0编辑  收藏  举报

导航