My problem is that when i click on a tab it will refresh the whole page and will call in each page load event of all the usercontrol of each view.
How can i change my code so that when clicking on a tab it will only load the page load event of this tab.
To achieve the above requirement, you can try adding an updatepanel to the outer table of the page you are providing. This will ensure that the whole page will not be refreshed when you click the button.
To make sure it enters only the page_load event of the current user control while clicking a tab button, I recommend that you dynamically load the corresponding user control in the click event. Below is a working sample, you can refer to it.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
In each webcontrol i have a gridview and the grid have buttons in the TemplateField(to save,edit,update,delete) each button have a function in the server side when clicking this button.
but now when i click the button to add a new row for example ,nothing happens and the server sides is not called.
i remember you that the update panel is on in the content page with multiple views that load each time a webusercontrol that contain a gridview.
According to your description,the reason why the data in the user control disappears when clicking on the button is that the user control is not rebounded when page reload.
If the click event is created in the code behind, the page cannot distinguish which user control you want to show after click on when loading.
So I suggest that you write the click event in the foreground jquery.Then pass different parameters through a HiddenField control to load different user controls.
Note that since jQuery rewrites some controls after pageload events, it is necessary to rebind tab click events in the add_endRequest event of PageRequestManager.
For more detailed code, please refer to the following code:
None
0 Points
3 Posts
refresh only part of page whit tabs
May 02, 2019 10:33 AM|carol254|LINK
Hello,
I have a master page and one content page.
In the content page i have tabs .Each tab is a button and when clicking on the button(tab) it activate the according view.
In each view i have a usercontrol that have gridView with data that is loaded.
My problem is that when i click on a tab it will refresh the whole page and will call in each page load event of all the usercontrol of each view.
How can i change my code so that when clicking on a tab it will only load the page load event of this tab.
Thank you
Star
9831 Points
3120 Posts
Re: refresh only part of page whit tabs
May 03, 2019 06:41 AM|Brando ZWZ|LINK
To achieve the above requirement, you can try adding an updatepanel to the outer table of the page you are providing. This will ensure that the whole page will not be refreshed when you click the button.
To make sure it enters only the page_load event of the current user control while clicking a tab button, I recommend that you dynamically load the corresponding user control in the click event. Below is a working sample, you can refer to it.
code behind
Test Result:
Best Regards,
Brando
None
0 Points
3 Posts
Re: refresh only part of page whit tabs
May 16, 2019 08:17 AM|carol254|LINK
Thank you so much Brando,
It works but i have now another problem:
In each webcontrol i have a gridview and the grid have buttons in the TemplateField(to save,edit,update,delete) each button have a function in the server side when clicking this button.
but now when i click the button to add a new row for example ,nothing happens and the server sides is not called.
i remember you that the update panel is on in the content page with multiple views that load each time a webusercontrol that contain a gridview.
how can i make it works?
thank you for your help
Contributor
3710 Points
1043 Posts
Re: refresh only part of page whit tabs
May 20, 2019 09:18 AM|Yongqing Yu|LINK
Hi carol,
According to your description,the reason why the data in the user control disappears when clicking on the button is that the user control is not rebounded when page reload.
If the click event is created in the code behind, the page cannot distinguish which user control you want to show after click on when loading.
So I suggest that you write the click event in the foreground jquery.Then pass different parameters through a HiddenField control to load different user controls.
Note that since jQuery rewrites some controls after pageload events, it is necessary to rebind tab click events in the add_endRequest event of PageRequestManager.
For more detailed code, please refer to the following code:
code behind:
The result of my work demo:
Best Regards,
YongQing.
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.