Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I try to call gridview and pop up on one button click

pop up

What I have tried:

JavaScript
<script type="text/javascript">
  $(function () {
      $("#divcontainer").dialog({
          modal: true,
          autoOpen: false,
          title: "Chart",
          width: 600,
          height: 450
      });
      $("#search_data").click(function () {
          $("#divcontainer").dialog('open');
      });
  });

button

ASP.NET
<input type="button" ID="search_data"    runat="server" 
class="sear_btn"  value="Search Data" OnServerClick="search_data_Click" />


now when i remove this OnServerClick="search_data_Click" from button then pop up display and grid view not display and when i add this then pop up not appear grid view display

whereas i want both on one button any solution?
Posted
Updated 13-Jul-16 5:36am

1 solution

That is normal. Web is stateless, your popup runs on the client/browser. Invoking the OnServerClick will cause a page to do a server postback, thus recreating the page. In other words, your popup will disappear when you trigger a server postback. Bottom line is you can't do server and client operation at the same time.

Now here are your options:

1) You could use your existing popup function and remove the OnServerClick. Then you could write a JavaScript/jQuery function that will do an AJAX requrest to the server to call a server-side method.

2) Get rid of your client-side popup, and instead use a server-side AJAX Dialog, for example the ModalPopupControl from AJAXControlToolkit. That way you can still invoke your OnServerClick event and call the ModalPopUpControl from your server code
.

3)You can probably do a hack, and that is to add a hiddenfield to mark a page if it postbacks, and decide if you show the popup. Though, I haven't tried it yet, so I cannot guarantee if it will work. ;)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900