Im trying to make a certain part of my website without postback when the user click a button.
I used Ajax through asp.net (Placed ScriptManager, and an UpdatePanel) , and I know that I need to serround my content in a ContentTemplate, but it seems that I cant, because I have a “Div” there…
this is my code WITHOUT a contenttemplate:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<p>
Some Text</p>
<p>
If you dont have a username yet, you can register <a href="Register.aspx">here</a></p>
<div id="LeftDiv">
<asp:TextBox ID="HowMany" runat="server"></asp:TextBox>
<br />
<br />
<asp:Panel ID="Panel2" runat="server">
<asp:Button ID="StartToGenerateButton" runat="server" Text="I know it!"
OnClick="StartToGenerateButton_Click" />
</asp:Panel>
<br />
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please enter your discovery"
ControlToValidate="HowMany" Display="Dynamic" ForeColor="Red"
Font-Bold="True" Font-Size="Small"></asp:RequiredFieldValidator>
<br />
</div>
<!--LeftDiv-->
<div id="RightDiv">
<asp:ListBox ID="ListBox" runat="server" Height="200px" Width="120px"></asp:ListBox>
<br />
<br />
<asp:Panel ID="Panel1" runat="server">
<asp:Button ID="youWon" runat="server" onclick="youWon_Click" Text="You Won!" />
</asp:Panel>
<asp:Label ID="ErrorMessege" runat="server" ForeColor="Red"></asp:Label>
</div><!--RightDiv-->
<div class="clearBoth">
</div><!--clearBoth-->
</asp:UpdatePanel>
how can I go through that ?
Is this what you mean?
You can put your entire content including the div in the content panel of the update panel. Anything in the content template area will postback independently of the main page. You will get a partial postback.
Does that help?
EDIT
To trigger a postback of the panel from a control outside of it then you will need to use the postback trigger element of the update panel to specify the control that should trigger the update
.
See this MS article for (extensive) detail