Give control back to the first page after Server.execute() - asp.net

I have a registration.aspx page. After entering all the information, user has to press the register button, which will add it to the DB. After that it shows a message that says "registered successfully".
To do this I created a separate web form to display the success message. So after the process happens successfully I simply call this separate .aspx file by using
Server.Execute("~/AlertMsg/ValidationMsg.aspx");
So everything is fine. The user can see a beautiful box at the top of the page. But the problem is after executing the 2nd page (ValidationMsg.aspx) inside the 1st page, control goes to the 2nd page. Because of that, if I click a dropdown or button in my 1st page (that has autopostback enabled), my page only shows the validation window.
What I wanted to do is to take control back to the 1st page after executing the server.execute. What should I do? Is there any good way to do this? I don't want to use JavaScript.
Below green color box is my separate web form.
Image 1:
Image 2 (after registering):

Related

Browser redirect to previous page after entering in input fields

I have 2 pages.
Login page
Search page (after login)
On my search page, I have several input box (text, radio, checkbox ...) .
The problem is, when the cursor is at one of the input fields, and the user presses Enter, the browser send the user back to the login page.
I fixed this issue using JQuery to capture keypress event on input items. However I still don't understand why is this happening?
P/s : if you need to see my HTML code please comment. The code stays on my work computer with restricted access so I can't post it here, but I will type it here if necessary.
Place your input inside a panel and set the default button to your default control.
<asp:Panel runat="server" ID="pnlForDefault" DefaultButton="btnSearch">
<!-- your input -->
</asp:Panel>
Now why is going back - and why I show you this panel method.
1. Maybe because you all ready have this panel on your page with wrong default button.
2. The user can press enter either when its on a text box, but also at any time, but only when the focus is inside a text box can be actually redirect that enter to some control. So either you may have some other library that take action on enter, either you press enter when you are focus on go back button....
You can also read
Default button not working in asp.net panel

Page does not move to top update panel inside user control

I have a user control on a ASP.NET page. Inside the user control there is a update panel. The page is a little lengthy and has Validation Summary control at the top.
The Submit button is at the bottom of the page. When I click the submit and when client side validation fails (on requiredfieldvalidators), the page DOES NOT move to the top where the Validation Summary control shows the messages. It just moves till the user control which is in the middle of the page.
I tried settings MaintainScrollPositionOnPostback="true" on the aspx page, but that didn't work.
How can I make it so when client-side validation fails, it moves to the top of the page?
Thanks
If the validation fails try to focus a control that is near the validation summary, maybe that work. ie. txtName.Focus(). If the validation is happening in the client side, try to do some js to detect when the summary appears....

Browser back button does not move to the previous View

I am using views concept in my asp.net form control.my first view consist of a form to capture user details.when user press continue it will move to the second view.
The problem is ,When user press the back button of the browser from the second view it doesn't move the the previous view instead move to the previous page in the browser history.
I wanted to move to the first view with the existing data in the form,when user press the back button of the browser.
You should perform a full page postback I guess, so that at client end your previous view will be saved in browser's history.

problme with changing control values from a diffrent page

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

which Asp.net page properties to work with ...? please find details below

I am having an application where I am displaying an modal dialog if the page is getting loaded for first time but when i navigate to any other page within the web site then also the modal dialog get displayed what i need is modal diaolg should get displayed only for first time and not while navigating within web site. "Just one time display of modal dialog to user not again and again if user navigates within website"
The modal dialog is coming from javascript and i am using asp.net 3.5
and not using ispostback any suggestion or condition other than ispostback is needed
Is there any property of page which is true/false for first time the page is loaded and gets false/true when the user navigates to other page within website...?
any way/logic to do it ...?
Thanks,
Nilesh
There is no property that will allow you to determine whether the pageis accessed for the first time or not. One way to handle this is to use a Session variable where you could store whether the user has already visited the first page.

Resources