I have a user control (toolbar). It is located in the master page and most pages in the project use this master page and therefore the toolbar user control. Print button in the toolbar control has to open print page in a new window. It is a hyperlink with target = '_blank'. In most of the pages it opens in a new window and in only one page it opens in the same window (which is wrong). This weird page has the same master page and hyperlink properties is the same during debugging.
Sounds strange, I would check the markup of that specific page where target="_blank" doesn't work and see if it contains any broken markup which could possibly cause that behavior. Maybe the attribute isn't read correctly on that page due to invalid markup somewhere else on that same page.
Related
i am using c# aspx , what i'm trying to do is to change a button.visible value from another page.
my page is build from 1 main page and 2 iframes ,the main page uses as a menu, iframe 1 is a login page and iframe 2 is the pages of my site.
on the menu page i have an admin control button which allows me to edit my database , this button visibility is false by default, then , if an administrator is logged in at the login iframe, the button should get visible.
i have tried in so many way to change that button but none worked ,
what i have tried so far:
1) send the button in a session ,recive on other page and change -not working
2) send the whole page and change - not working .
3) make the button public static and change - not working .
i have noticed that even when i change the text on the button on the other page ,on the menu page (the page where the button lays) the button didn't changed it's text.
anothere thing i have noticed is when i press a button on a page , the page is sort of updating (like refreshing but keeps values) , is there a way to make this kind of update manualy?
thanks .
I am assuming from your description that you are trying to change the visibility of the button on the other frame from a post back within the log in frame. The short answer is that this will not work because there is nothing being sent from the server to the client for the other frame.
Your would need to set the visibility of the button in a post back of the page containing the button (which is in the other frame).
It may be better to remove the use of frames and use a master page to provide the log in portion of your page/site as this would allow you to change the visibility of the button in a post back for any page on your site.
For the attempts that you have tried, all three of these should be avoided because the controls are recreated every post back when the page is recreated and will also be disposed every post back in the unload of the page. Since the control and page would be disposed on the first request if you access it on a subsequent call to the server there is no guarantee that the state of the page or control is valid.
For more details on the life cycle of a page, look at the ASP.NET Page Life Cycle Overview:
http://msdn.microsoft.com/en-us/library/ms178472.aspx
ASP.NET 4.0 Webform website
master page:
left side panel (navigation menu purpose): use UpdatePanel control (AJAX), so when selecting new menu, the whole page won't reload. Only content part will be updated.
My question is -- I want to be able to use browser back button to go back to previous menu (with form state saved). However, when looking into the viewstate, it's always the same. Is there any way to do this? Thanks.
I guess one work around would be, when a user selects a menu item from the menu, put that selection in a session variable and in the page load. Then when the user hits the browser back button, you can set the menu in the page load, since you have values in your session variable.
What pst is referring to is "cross-page posting".
On your source page, you will need to set the asp button's postbackurl to your target page url.
In the target page c# onload method, set page.previouspage to your source page. Check if the previouspage's post was a crosspagepost.
If true, get zource page's viewstate.
How do you get access to the source page's viewstate from the target page? Save the source page's viewstate in the source page before going to the target page. Save the viewstate in an asp hidden variable on the source page, then get it in the target page using previouspage.findcontrol("variable name").
After getting the source page's viewstate, save it in an asp hidden variable on the target page.
When you want to return to the source page, you will do everything above in reverse, in a way.
The "back to previous page" link button will use the source page url for the postbackurl value.
In the source page's onload c# method, set the page.previouspage url to the target page's url. Check if the previouspage's post was a cross-page post.
If true, in the source page (after returning from target page) use previouspage.findcontrol("savedSourcePageViewstate") to get the saved viewstate of the source page.
I am not exactly sure yet how to then change the source page's viewstate to the saved viewstate. you might actually have to do it in the target page's backttopreviouspage button's click handler.
I am working at developing this process right now in a project i'm developing at work.
When i get it working, i'll create a full walkthrough for this, with code examples, and post the link to the walkthrough here.
However, i already haveworking the cross-page posting process of getting data from the source page in the target page.
It is secure, and is the best method that i have come across for getting data from one page to anotherin an asp.net webforms application.
I am using IFrame in my ASP.NET pages. For the page that I am referencing in my IFrame, I have a gridview (I also have CommandField that referencing another asp.net page) and paging enabled.
I wanted to display a new page (outside of Iframe) when a user clicks on the commandfield in the gridview. In order to do that I set form's target to "_parent". This works fine (it open a new page outside of Iframe). Now, my problem is that when i click on the paging to go to next page in the gridview, it also opens the gridview outside of IFrame (which I dont want to happen). I want it to open within the Iframe.
Is there any way I could set the target as I needed?
Thanks.
Use some jQuery: (Just threw this idea together, not tested)
$("#myElement").click(function() {
if(window.location != window.parent.location)
{
// window is in iframe
$(this).attr("target", "_self");
}else{
$(this).attr("target", "_parent");
}
});
I have a page showing all products in a gridview.
I have a link in the page clicking on it opens a modal window.
In the modal window there is a form to enter product and save.
When I fill the form and save product I need to make the parent page to be refreshed so that
the new product is listed in the gridview and a message will be shown in a label in the modal window. I need to refresh the product list page without closing the modal window.
How to do it?
Please help.
You can refresh it with the following JavaScript:
window.opener.location.reload(true);
window.opener.location.reload(true);
true makes sure that the page is reloaded from the server instead of the browser's cache.
This will work only if the second page was opened by the first page using javascript and not when you open a link in the first page in a new window - window.opener will be null in the later case. Even in the former case, Firefox will throw a 'permission denied' error if both pages are not from the same domain.
I was wondering if there is way to open another page using a Modal Popup Extender?
and if there is can someone please the tell me how do i go about doing it ..
Thanx
Owais
You could probably put an iframe pointing to the page within the Modal Popup Extender, however that would be a bit of a hack. I would recommend putting whatever content on that page into a user control and then referencing that control from both the original page and the page with the modal popup.
Try using an HTML iframe as the target control of the extender. The iframe tag has a "src" attribute that should point to the page you want to show in the dialog.
You have to think about it w/o the illusion - fundamentally the modal popup is just a DIV. So the question is "can you display a different page in a div?". Iframe... or perhaps a webservice call.
you can use a user control and load it dynamically into the modal popup
Dim ctrl As Control
ctrl = Me.Page.LoadControl("~/control/cmsbar.ascx")
ctrl.id="ctrlx"
Placeholder1.Controls.Add(ctrl)
popup.Show()
note that the popup will have a placeholder to add the control to. you must give the user control an id so the viewstate can be loaded for the control . this code must be placed in the Page_Init event so when the user control is created for the second time it loads its view state