0

I got one question, and I try to search in the forums, but I can't seem to put this to good use. I have a simple website using a master page, everything works fine, I even put a navigation bar and works nicely :)

But I'm trying to change my maincontentplaceholder using javascript, I try with location.href and a solution I quite get for now which is __PostBackURL but I get a full refresh of the page and I lost the "master page" (header).

My Master page:

<asp:ContentPlaceHolder runat="server" ID="header" >   

        <table>            
            <tr>
                <td>                         
<div id="navigation" class="navBarHidden" runat="server">
                        <img src="images/upperBar.png">
                        <div class="btns">
                            <table class="menu">
                                <tr>  
                                    <td style="width:15%"></td>                                        
                                        <asp:Repeater runat="server" ID="Repeater1" DataSourceID="SiteMapDataSource1">
                                            <ItemTemplate>
                                                <td style="width:12%; text-align:center;" >
                                                    <asp:HyperLink ID="HyperLink1" runat="server"  NavigateUrl='<%# Eval("Url") %>'><%# Eval("Title") %></asp:HyperLink>                                                          
                                                </td>  
                                            </ItemTemplate>
                                        </asp:Repeater>                                                                        
                                    <td style="width:15%">
                                        <div id="loginLabel" style="color:white;">
                                            login
                                        </div>
                                        <div id="loginArea" class="loginAreaClosed">
                                            <table>
                                                <tr>
                                                    <td>
                                                        <input type="text" id="login" class="loginInput"/> 
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <input type="password" id="password" class="loginInput"/>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <input type="button" value="login"/>
                                                    </td>
                                                </tr>                                                                                                
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                             </table>                                                                                                                                            
                        </div>
                    </div>                                 
                </td>
            </tr>
        </table>
    </asp:ContentPlaceHolder> 

<div class="content">
   <asp:ContentPlaceHolder runat="server" ID="ContentPlaceHolder1" >
</asp:ContentPlaceHolder>

And the several container.aspx they are the same for now:

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<div class="containerAll">
    <div class="container">

    </div>
</div>

</asp:Content>

In one of this containers I have a .js file with some stuff:

document.getElementById("ContentPlaceHolder1_icon1").addEventListener('click', action, false);

function action() {
   // i want to change the page seen in the main container inside the master page
   // i tried
   window.location = 'Response.Redirect("~/events.aspx", false);'
  // and this tried
 window.location = "newStuff.aspx";
}

I know this is kind of messy :( Is this possible?

Hope someone can tell me there is a way :)

4

1 回答 1

0

这不是 MasterPages 的工作方式,请阅读这篇文章: http: //msdn.microsoft.com/en-us/library/wtxbf3hh (v=vs.100).aspx

于 2013-06-07T18:32:25.743 回答