I have a FormView that has two buttons on them. What I need to happen is when the user clicks on the buttons, a popup window is displayed. The data in this window is being pulled from a stored procedure in which I will need to pass variables. Can someone supply code on how to do this?
Create a new page. This is your popup (ie popup). On the your calling page add a hyperlink that calls you popup page but make sure the Target attribute is set to _new which tells the link to open a new browser instance.
Open popup page.
In your pop up page you would then call your ADO.net sql specific code in the Page_Load event.
Are you passing a url encoded variable to this page?
Related
I'm very very new to asp.net, and in my tour of its features I found that if you use Server.Transfer instead of Response.Redirect then, among other things, you could preserve the URL of the original page. I created two test pages.
The first has a textbox and a button. When you click the button, the contents of the textbox are saved in the Session variable and Server.Transfer is used to load the second page. On this page there's a button and a label. When you click the button, the label gets populated with what was saved in the session variable.
The issue is, when I click the button on the second page and the label is altered, the URL changes to that of the second page. This seems a bit to defeat the purpose, so how do I go about preserving the URL?
Clicking the button on the second page is causing a postback and the server is showing the URL of the page you are posting back to (the second page). In effect, you have done a Response.Redirect to yourself.
I am curious as to why you want to have two separate .aspx pages behave as if they are only one. One of the major drawbacks of using Server.Transfer is the confusion it causes the user when they think they are on a new page, but the browser says otherwise; especially in bookmarking scenarios.
If you want the logic to reside in a single .aspx page, but act as two separate logical units, then I suggest you use ASP.NET Panel controls that show/hide the logic as needed and the page's code-behind can react to the necessary events (i.e. button clicks) all in one page and the URL will be the same the entire time.
I have to fix one issue in our application that, If child window is opened and user clicks on Browser back button i need to redirect to page asking username and password.
we have 400 aspx pages so just i need to modify in master page. I have code like below
function initPage(){
checkback();
}
This function is written in external javascript file and used in Master Page.
checkback function contains code like below
if (document.forms[0].cprotection.value=='1')
{
document.forms[0].pagecode.value=0;
document.forms[0].act.value='backpressed';
document.forms[0].submit()
}
The above code is working fine for parent window but not if i open child window.
backpressed is keyword am using to check in class file to redirect to page asking username and password. Please help me out in fixing this issue. Thanks in advance
You could add a variable to the session when the child window is loaded and if the user clicks back you would check the session to see if the variable that the child window added to session is nothing inside whichever pages load function and if it is then load normally, if its not redirect to the login page.
I have a .net 3.5 page which has a form control (form1) and with that form is an iframe which contains a page which contains a form (form_tester). What I am trying to do is submit form1 and at the same time submit form_tester that is within the iframe, how do you do that? I know I can submit the form via javascript but I am just wondering if there is a standard way, or a better way of doing it?
Thanks.
I did it in the end by adding a button to the page (form) the was encapsulated within the iframe. Then I added an onclientclick event to the submit button. I then added some javascipt which clicks the button on the encapsulated page and hence it get's submitted. The hardest part was working out how to access the elements on the encapsulated form.
window.frames["frame1"].document.forms['hidden_form']["submit_btn"].click();
but it does work.
I have an updatepanel,a modal popup extender inside that and an image button to open the pop up(it has not any click event). The 'div' for the modal pop up is outside the updatepanel. In the modal pop up the records come in a table with a link in each table row.When the link is clicked,a javascript function causes a hidden control to postback and fetch values from database.First time it is working fine,but next time the image button(TargetControlID for modal pop up extender) does not work and it is causing a postback and loading the page.Help plz...
Thanks in advance.
Mohak
Are you using myLink.ClientID or did you hardcoded the ID of the link in the Javascript function?
The ID of the link is probably changed when doing the first postback, the second time ASP.NET has generated a new ID (not visible in the HTML because of the AJAX-request) for your link and this doesn't match anymore with the ID in your Javascript function.
The solution would be to use myLink.ClientID
How to get the parent page name of the modal popup dialog? I have one page that is using in two or more pages by using modal popup. When the close button of the modal popup dialog window, it will redirect to the orgin. But where from we will get the parent page name by programmatically?
You can get a reference to the parent from javascripts window.opener object, if the current window was indeed opened in a popup/modal dialog.
As David says, you can use window.opener to get the page that opened a popup window.
However, if you're using a ModalPopupExtender from the AJAX Control Toolkit then you'll likely already be on that page, in which case you'd need to hook up something to the OnOkScript or OnCancelScript attributes of the extender to refresh the page.
If you could post some code it'll make it easier to offer a solution.