1
votes

i am tried like this, i take an button control which display is none:-

<div style="display:none">         
   <asp:Button ID="loginbtn" runat="server" OnClick="loginbtn_Click" />  
  </div>

Then I call the click event of the button through jquery:-

  $("input[id$=loginbtn]").click();

in Server side I call button event:-

protected void loginbtn_Click(object sender, EventArgs e)
 {

 }

Its working fine,But,it reload the page, I need to Stop it , Please give me some solution how to call the server side method from client side in DNN

2

2 Answers

1
votes

In this case (I'm assuming you are developing a module for DotNetNuke); The easiest way is to check "Supports Partial Rendering" in your module control. Then it will be wrapped by an Update Panel.

Host -> Extensions -> Edit your module -> Module Definitions -> Module Controls -> Edit your module control -> Check Supports Partial Rendering

However, if a control already contains JavaScript for dynamic behaviors, wrapping the control in an Update Panel has the potential to break the control's functionality.

0
votes

There are a couple of ways to do this, say, using an UpdatePanel or changing your mechanism to use AJAX directly with WebMethod methods; let me introduce the easiest example for your case before you consider more. Wrap your content in an update panel, as such:

<asp:UpdatePanel runat="server">
  <ContentTemplate>
    <!-- stuff to reload here  -->
  </ContentTemplate>
  <Triggers>
    <asp:AsyncPostBackTrigger ControlID="loginbtn" EventName="Click" />
  </Triggers>
</asp:UpdatePanel>

So, then the other option is to use jQuery's ajax or equivalents (such as post) to submit your data programatically (rather than somewhat macroing the UI - which might not even work in some browsers such as versions of IE). The AJAX call can return data and you can populate your pieces in place as required.