简体   繁体   中英

Calling server side function from client side

I am using Asp.Net/C# in my application.My current situation is that I am using Jquery tabs on one of my pages , I have tabs in the following order

  1. Personal Details
  2. Additional Details
  3. Submit Data
  4. Show Records

On the tab Show Records I am allowing the user to enter customer name whose records will be displayed in Asp.Net Gridview Control , The GridView is populated with the data on the click of an Asp.Net Button , My issue here is that when the user clicks the button , as it is a server control the page is refreshed and the Personal Details tab is shown and the the user needs to go to the tab Show Records to view the data in the Grid View .It shows the data from the database properly , but It is not what I need.When the button is clicked the tab Show Record should be visible.One solution I researched was to use Html button and call the function from client side.Can you guys suggest me some solution or using the html button is the best solution. Thanks

append that code to your button click function on server-side

string script = "ShowRecordsTab();"
ScriptManager.RegisterStartupScript(this, this.GetType(), "RecordsTab", script, true);

and add this js code to your view

<script>
    function ShowRecordsTab(){
         $("li:last").click();
    }

</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM