2017-05-11 27 views
0

我有一個登錄頁面和一個下拉列表,您可以爲網站選擇背景顏色。但是,我無法將主頁的主體與下拉列表中選定的值鏈接起來。如何從另一個頁面訪問MasterPage主體

<body style="overflow: auto;" runat="server" id="bodyMasterPage"> 

這是我的MasterPage主體的開始標記,這裏是我得到的下拉列表。

  <div class="col-sm-3 col-sm-offset-4"> 
      <div class="input-group input-group-sm"> 
       <asp:Label runat="server" ID="lblColor" ClientIDMode="Static" AssociatedControlID="ddlColor" class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></asp:Label> 
       <asp:DropDownList runat="server" ID="ddlColor" ClientIDMode="Static" aria-describedby="lbColor" data-taggle="dropdown" data-style="DropDownListHint-datastyle" class="btn dropdown-toggle DropDownListHint-datastyle"> 
       <asp:ListItem Text="Бял" Value="White" Selected="True" /> 
       <asp:ListItem Text="Зелен" Value="Green" /> 
       </asp:DropDownList> 

      </div> 
     </div> 

回答

1

使用Master.FindControl方法

var body = Master.FindControl("bodyMasterPage"); 
相關問題