<%@ page language="C#" autoeventwireup="true" inherits="PartMgmt_BindContent, App_Web_o7zimql7" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>部件属性 - 内容绑定</title>
    <base target="_self"/>
    <link rel="stylesheet" href="../Style/Common.css" />
    <link rel="stylesheet" href="../Style/Dialog.css" />

    <script type="text/javascript" src="../Script/Common.js"></script>
    <script type="text/javascript">
var hfVirColTitle, hfNewName, hfNewTitle, hfOldName, hfTitle;
var hfContField, hfPartField, tbColumn, fieldRadios, btnEditCont;
function Page_Init()
    {
	hfVirColTitle = $('hfVirColTitle');
        hfNewName = $('hfNewName');
        hfNewTitle = $('hfNewTitle');
        hfOldName = $('hfOldName');
        hfTitle = $('hfTitle');
        
	hfContField = $('hfContField');
        hfPartField = $('hfPartField');
        tbColumn = $("tbColumn");
        btnEditCont = $("btnEditCont");
        fieldRadios = document.getElementsByName('fieldRadios');
        
	var ConfigTab = $('ConfigTab');
        var StyleTab = $('StyleTab');
	var query = location.search;
	ConfigTab.href = 'Setting.aspx' + query;
	StyleTab.href = 'Style.aspx' + query;
    }

var SiteName, PagePath, CtrlId, OldColName;
function Page_Load()
    {
	SiteName = Common.GetQueryString('sitename');
	PagePath = Common.GetQueryString('pagepath');
	CtrlId = Common.GetQueryString('ctrlid');
	if( !SiteName || !PagePath || !CtrlId ){
	    window.close();
	    return;
	}
	
        tbColumn.disabled = true;
        tbColumn.value = hfTitle.value;
        
        OldColName = hfOldName.value;
        if( OldColName ){
            btnEditCont.disabled = false;
        } else{
            btnEditCont.disabled = true;
        }
        
        var inputs = document.forms[0].elements;
        for( var i=0; i<inputs.length; i++ ){
            var input = inputs[i];
            if( input.nodeName=='INPUT' && input.type=='radio' ){
                var span = input.parentNode.nextSibling;
                if( span.innerText==' ' )
                    input.style.display = 'none';
            }
        }
    }
function SelectField( obj )
    {
	hfContField.value = obj.value;
    }    
function btnBind_Click( obj )
    {
	hfPartField.value = obj.nameType;
    }
function btnSelect_Click()
    {
	var url = new UrlText( '../PartConfig/SelectColumn.aspx', ['SiteName', SiteName], 'uni' );	
	var ret = Common.ShowDialog( 3, url.Text, null, {width:420, height:480} );
	if( ret && ret.name && ret.title ){     //alert(ret+'    '+ret.name);
	    hfNewName.value = ret.name;
	    hfTitle.value = ret.title;
	}
    }
function btnNewCol_Click()
    {
	var arg = { DialogMode: 'AddColumn', 
	            DefaultTitle: hfVirColTitle.value };

	var ret = Common.ShowDialog( 11, '../CommonUI/NewTitle.htm', arg );
	if( ret && ret.name && ret.title ){
	    hfNewName.value = ret.name;
	    hfNewTitle.value = ret.title;
	} else{
	    return false;
	}
    }
function btnEditCont_Click()
    {
	var url = new UrlText( '../PartConfig/ContentList.aspx', ['SiteName', SiteName], ['colName', OldColName], 'uni' );
	var ret = Common.ShowDialog( 3, url.Text, null, {width:760, height:500, offset:true} );
//	alert(ret);
    }
    </script>
</head>
<body><form id="form1" runat="server">
    
    <div class="TopArea">
        <h1>部件属性
            <asp:Label ID="lbPartName" runat="server" Text="[]" CssClass="Notes" />
        </h1>
        <div class="HeadLogo"></div>
    </div>    
    
    <div class="TitleBar">
        <table style="width:98%; margin:3px auto;"><tr>
            <td style="width:80px;">选中的栏目：</td>
            <td>
                <input id="tbColumn" type="text" style="width:98%;" /></td>
            <td style="width:260px;">
                <asp:Button ID="btnSelect" runat="server" Text="选择栏目" CssClass="Button" OnClientClick="btnSelect_Click();" OnClick="btnSelect_Click"  />
                <asp:Button ID="btnNewCol" runat="server" Text="新建栏目" CssClass="Button" OnClientClick="btnNewCol_Click();" OnClick="btnNewCol_Click"  />
                <input id="btnEditCont" type="button" value="编辑内容" class="Button" onclick="btnEditCont_Click();" />
            </td>
        </tr></table>
    </div>
    
    <div class="ContentArea" style="height:390px; overflow-y:auto; margin:6px 16px;">
        <asp:GridView ID="GridView1" CssClass="DataTable" cellspacing="1" runat="server" AutoGenerateColumns="False" >
            <Columns>
                <asp:BoundField HeaderText="部件要求字段" DataField="pShow">
                    <ItemStyle HorizontalAlign="Right" Width="45%" />
                </asp:BoundField>
                <asp:TemplateField HeaderText="绑定">
                    <ItemTemplate> 
                        <asp:Button ID="btnBind" runat="server" Text="<<" OnClick="btnBind_Click" OnClientClick="btnBind_Click(this);"></asp:Button> 
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="选择">
                    <ItemTemplate>
                        <input name="fieldRadios" type="radio" onclick="SelectField(this);" value='<%# DataBinder.Eval(Container.DataItem,"cCtrl")%>' />
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="栏目提供字段">
                    <ItemTemplate>
                        <asp:Button ID="btnCreateField" runat="server" Height="21px" OnClick="btnCreateField_Click" OnClientClick="btnBind_Click(this);" Text="创建" Width="31px" />
                        <asp:Label ID="lbBindField" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"cShow")%>' ></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="45%" />
                </asp:TemplateField>
            </Columns>
            <AlternatingRowStyle CssClass="Alternating" />
        </asp:GridView>
    </div>
    
    <div class="BottomArea">
        <span class="LeftBlock">
            <asp:Label ID="lbResult" runat="server" ForeColor="Red"></asp:Label>
        </span>
        <span class="RightBlock">
            <asp:Button ID="btnConfirm" runat="server" CssClass="Button" Text="确定" OnClick="btnConfirm_Click"/>
            <input id="btnCancel" type="button" class="Button" value="取消" onclick="window.close();" />
        </span>
    </div>
    
    <%-- 顶部选项卡  放到后面，防止开始时获得焦点 --%>
    <div class="TabArea" style="left:221px; width:270px;">
        <a id="ConfigTab" class="NormalTab"><span>设置</span></a>
        <a id="StyleTab" class="NormalTab"><span>样式</span></a>
        <div id="BindTab" class="ActiveTab"><span>内容绑定</span></div>
    </div>
    
    <asp:HiddenField ID="hfVirColTitle" runat="server" />
    <asp:HiddenField ID="hfNewName" runat="server" />
    <asp:HiddenField ID="hfNewTitle" runat="server" />
    <asp:HiddenField ID="hfOldName" runat="server" />
    <asp:HiddenField ID="hfTitle" runat="server" />
    
    <asp:HiddenField ID="hfContField" runat="server" />
    <asp:HiddenField ID="hfPartField" runat="server" />
    
</form>
<script type="text/javascript" language="javascript">
try{ Page_Init(); }catch(ex){;}
try{ Page_Resize(); window.onresize=Page_Resize; }catch(ex){;}
try{ Page_Load(); }catch(ex){;}
</script>
</body>
</html>