c#
  • javascript
  • jquery
  • asp.net
  • 2013-06-05 2 views 1 likes 
    1

    예 :asp.net에서 다중 뷰 컨트롤을 만들고 런타임에 조작하는 방법은 무엇입니까?

    <asp:MultiView 
         id="MultiView1" 
         ActiveViewIndex="1" 
         Runat="server"> 
         <asp:View ID="View1" runat="server" > 
          <iframe id="v1" runat="server" src='http://www.w3schools.com' style="border: None; height: 100%; width: 100%;"></iframe> 
         </asp:View>   
         <asp:View ID="View2" runat="server"> 
          <iframe id="Iframe1" runat="server" src='http://www.w3schools.com/html/html5_intro.asp' style="border: None; height: 100%; width: 100%;"></iframe> 
         </asp:View>   
         <asp:View ID="View3" runat="server"> 
          <br />This is the third view 
          <br />This is the third view 
          <br />This is the third view 
          <br />This is the third view 
         </asp:View> 
         <asp:View ID="View4" runat="server"> 
          <br />This is the third view 
          <br />This is the third view 
          <br />This is the third view 
          <br />This is the third view 
         </asp:View>   
        </asp:MultiView> 
    

    우려 :

    1. 어떻게 실행시에, 멀티 뷰 구조를 만들려면?
    2. 멀티 뷰에서 사용할 수있는 iframe의 대안이 있습니까?
    3. 두 개 이상의 메뉴에 대해 하나의 멀티 뷰보기를 사용할 수 있습니까?
    4. 자바 스크립트 또는 jquery를 사용하여 다중보기를 참조하고 조작하는 방법은 무엇입니까?

    도와주세요.

    감사합니다.

    답변

    2

    이 답변은 마지막 질문과 유사합니다 : How to Show/Hide Menu Item and how to create it at run time?. 이 컨트롤을 프로그래밍 방식으로 추가하는 방법에 대해서는 다음 MSDN 문서를 참조하십시오. http://msdn.microsoft.com/en-us/library/kyt0fzt1(v=vs.100).aspx

    MultiView 컨트롤에 View 컨트롤을 동적으로 채우는 방법의 예는 다음과 같습니다.

    protected void Page_Init(object sender, EventArgs e) 
    { 
        // Create View. 
        View myView = new View(); 
    
        // Create controls. 
        Label myLabel = new Label(); 
        myLabel.Text = "<b>Test</b>"; 
    
        // Add controls to View. 
        myView.Controls.Add(myLabel); 
    
    
        //Add view to MultiView. 
        MultiView1.Views.Add(myView); 
        MultiView1.ActiveViewIndex = 0; 
    } 
    

    위의 논리는 프로그래밍 방식으로 페이지에 컨트롤을 추가 할 때와 동일합니다.

    Label myLabel = new Label(); 
    myLabel.Text = "<b>Test</b>"; 
    
    MultiViewDemo.Views[0].Controls(myLabel); 
    

    것은 그런 다음 정상으로 jQuery를 사용하여 해당 뷰에서 모든 HTML 요소를 조작 할 수 있어야한다 :

    당신은 인덱스로 특정보기를 참조하여 서버 측 코드를 사용하여 MultiView 제어 같은 방법으로 조작 할 수 있습니다 .

    MultiView에서 복수 Menu 컨트롤을 사용하는 것은 요구 사항에 따라 다릅니다. iframe에 관해서

    , 난 당신이 대안으로 찾고있을 것이다 모르겠어요,하지만 당신은 그들에게 runat="server" 속성을 추가 한 이후 서버 측 코드를 사용하여 iframe 컨트롤을 조작 할 수 있어야한다.

    +0

    감사합니다. 당신은 항상 도움이됩니다. –

    +0

    이것은 분명히 나를 도울 것입니다. :-) –

    관련 문제