Refresh master page from content page - c#

I want to refresh my master page from a User control which is on content page in update panel.
Problem is that my user control is in update panel and I cant take it out of that due to some reasons .Now I want to directly refresh my master page on button click of user control which is on content page.Thanks in advance.

The following javascript will refresh the master page...
<script type="text/javascript">
function reloadPage()
{
window.location.reload()
}
</script>

Related

How to load repeater controls after the page load in asp.net?

I want to load two repeater controls after the asp.net page is loaded completely. These two controls are populated by a button click event. Instead of the button being clicked by the user, I want that to be clicked by an ajax call - or by any other means - after the page is loaded.
I have followed the technique described here: http://forums.asp.net/t/1452988.aspx?how+to+load+gridview+after+the+page+is+completely+loaded.
Essentially it uses Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded); Once the pageLoaded event handle is obtained, it uses javascript to call the button click event. While it sort of works, the issue is that the page loading and the button click events are executed repeatedly. Because of this, the page flickers constantly. Please let me know how to resolve this issue.
Note: The site has a master page which has the scriptmanager.
<asp:UpdatePanel>
...More code here...
</asp:UpdatePanel>
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);
function pageLoaded(sender, args) {
var hdnLoadedPage = $get('<%= hdnLoaded.ClientID %>');
var btnApplyFilter = $get('<%= btnFilter.ClientID %>');
if (hdnLoadedPage != 'Yes') {
btnApplyFilter.click();
}
}
</script>
</asp:Content>
Thanks

Refreshing Datagrid to the Parent page on click from the IFRAME page

I have a ASP.net page which has a Datagrid to display all the Records of a Table. On Click of an Add Button pops up an IFRAME with different .ASPX page to be saved as a new record. I would like to add the new record to the Datagrid on the parent page from the IFRAME.
Please suggest how can I refresh the Datagrid alone without refreshing the entire page.
Note: The Save button is in IFRAME in an another page and the Datagrid is in another Page.
Thanks
If you just want to refresh Datagrid only , you may consider Ajax . Here is the link
Or You may also consider a java script to refresh the grid, here is the code to give you an idea
protected void grid_view_refesh()
{
grid_view.Bind();
}
Button:
<button id="btn_refresh" onclick="btn_refresh_click();">Refresh</button>
javascript
<script type="text/javascript" language="javascript">
function grid_view_refesh()
{
// you code to refresh grid
}
Hope it will help
EDITED
You can try this code on your popup windows ( Child window)
<script type="text/javascript">
function CloseWindow() {
window.close();
window.opener.location.reload();
}
<input type="button" value="Close Window" onclick="javascript: return CloseWindow();" />

Update label of MasterPage from content page when there is no ScriptManager in master page

I had not used ScriptManager on my MasterPage as it was not required when I started developing the project, so I have an individual ScriptManager and UpdatePanel for each content page.
In the MasterPage now I've added a label which shows the current system time, and my client wants it to change asynchronously and give a live clock feeling. Can I change the label text in the master page from the content page using Timer? So far I'm unable to achieve this, as I can't use an UpdatePanel also in the MasterPage because there is no ScriptManager tag.
So is there a way to achieve this?
Thanks # Yuriy Rozhovetskiy, From your suggestion i had created a simple javascript and called that javascript on Master page body on load and its working fine. Please find code below which may help to some one who also have same requirement:-
Javascript Function:-
<script type="text/jscript">
function clock(){
var d = new Date();
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
$('#clock').html(h+"<span class='colon'>:</span>"+m+"<span class='colon'>:</span>"+s);
// $('.colon').fadeTo(1000, .2);
setTimeout(clock, 1000);
}
<body onload="clock()">
Added this to display clock on master page.
<span id="clock" style="font-family:Calibri;color:White;font-weight:bold;font-size:1.3em;"></span>

get checkbox click inside updatepanel by jquery

I have an update panel with a runat server div inside,
this div isn't shown in the first load of the page. I used to show it after user input the search key then reload the update panel which contain the div and fill div controls then show it.
I have a CheckBox inside this div tag and I need to get the click event of this check box with jquery
I try to use direct .click or .live but all doesn't work !!
Any help will be appreciated.
Use this code
$(document).ready(function()
{
//This will add one function to be called on every request of the update panel
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
});
function EndRequestHandler()
{
$('#checkboxID').change(function(){
//Your functionality
});
}
You need to introduce javascript into the page to simulate the click event again. Page.RegisterClientScriptBlock or Page.RegisterStartUpScript should do it.
or
place this inside the updatepanel
<script type="text/javascript">
Sys.Application.add_load(your jquery function);
</script>

using master page

I have master page in asp.net.i want to display user in master page but in my knowledge master page is loading once at a time.How it possible when Session["User"] only get when login attempt.But master page is already loaded.
The master page renders with each page request, so if you have code that dynamically populates data on the page (for example, setting a label in Page_Load) it will populate on each subsequent page load. A master page can read from Session values just fine.
Have you tried something specific and it's not working?
try to put a breakpoint in pageload of aspx.cs and master page. Page will load first. and after that master page will load. So session added from page can be accessible form masterpage

Categories