473,405 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

validate fields, then launch new window

Hi;

In a page, when the user clicks on a button, I want to validate all the
controls (in the code behind) and then if they are good, leave that page
alone and launch a new window with a new url also.

This is what I think is the best approach - please let me know if there is a
better one:

In my code behind I validate everything.
I then set a flag as a session variable.
I then have it reload the page I am in (do I redirect to the page or is
there another way?).
When the page loads, I look for the session variable and finding it, I
create an onload script.
The onload script launches a 2nd window to the other url. (Is there a best
way to do this and to specify the url so pop-up blockers don't block it?)
I have a javascript variable named launched I set to true after launching so
on a reload I don't launch again.

???

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Jun 14 '06 #1
11 1653
"David Thielen" <th*****@nospam.nospam> wrote in message
news:33**********************************@microsof t.com...
In my code behind I validate everything.
Do you *actually* need to validate server-side? E.g. are you validating the
contents of the controls against a database...?
I then set a flag as a session variable.
I then have it reload the page I am in (do I redirect to the page or is
there another way?).
When the page loads, I look for the session variable and finding it, I
create an onload script.
??? Why do you need to reload the page at this point? Assuming you *do*
actually have to validate server-side, if validation passes why not simply
register a client script block...?
The onload script launches a 2nd window to the other url. (Is there a best
way to do this and to specify the url so pop-up blockers don't block it?)
If this is a public site, don't use showModalDialog as this doesn't work
with all browsers / versions. Use window.open instead.
I have a javascript variable named launched I set to true after launching
so
on a reload I don't launch again.


I think you may be over-complicating the process a bit...
Jun 14 '06 #2
Hi David,

Thank you for your post.

In an ASP.NET Page's life cycle, some related events order is:
1) Load
2) Validation
3) Postback event handling

You can refer to following article for more info:

#ASP.NET Page Life Cycle Overview
http://msdn2.microsoft.com/en-us/library/ms178472.aspx

So I think you can simply check the IsValid property in the control event
which caused the postback, for example:

protected void Button1_Click(object sender, EventArgs e)
{
if (IsValid)
{
ClientScript.RegisterStartupScript(GetType(), "open2",
"javascript:window.open('default2.aspx')", true);
}
}

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 14 '06 #3
Ok, will try this.

thanks - dave

ps - Yes unfortunately it needs to hit the DB for the validation.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

"Walter Wang [MSFT]" wrote:
Hi David,

Thank you for your post.

In an ASP.NET Page's life cycle, some related events order is:
1) Load
2) Validation
3) Postback event handling

You can refer to following article for more info:

#ASP.NET Page Life Cycle Overview
http://msdn2.microsoft.com/en-us/library/ms178472.aspx

So I think you can simply check the IsValid property in the control event
which caused the postback, for example:

protected void Button1_Click(object sender, EventArgs e)
{
if (IsValid)
{
ClientScript.RegisterStartupScript(GetType(), "open2",
"javascript:window.open('default2.aspx')", true);
}
}

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 14 '06 #4
Hi David,

I am interested in this issue. Would you mind letting me know the result of
the suggestions? If you need further assistance, feel free to let me know.
I will be more than happy to be of assistance.

Have a great day!

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 16 '06 #5
Hi;

I'm still fighting this. Two problems I am hitting:

1) popup blockers stop the popup.

2) what I want to do is when they click spawn a new browser and redirect the
existing page to a new page. The best I have come up with is I go to a 3rd
page that launches the new browser and then redirects - but I don't like this
solution.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

"Walter Wang [MSFT]" wrote:
Hi David,

I am interested in this issue. Would you mind letting me know the result of
the suggestions? If you need further assistance, feel free to let me know.
I will be more than happy to be of assistance.

Have a great day!

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 16 '06 #6
Hi Dave,

Thank you for your update.

As long as we're using JavaScript to open the new browser window, we cannot
do much with the popup blocker.

Do you think using Cross-Page PostBack here will be helpful? For example:

<form id="form1" runat="server">
<asp:Button id="button1" runat="server" text="button"
OnClientClick="form1.target='_blank';"
PostbackUrl="~/Default2.aspx"
</asp:Button>
</form>

This will survive the popup blocker, but Default2.aspx will always open.
And we need to check if the first page's valid or not in Default2.aspx:

if (PreviousPage != null) {
if (PreviousPage.IsValid) {
...
}
}

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 16 '06 #7
When I get a popup on dell.com it comes up even though I have blocking on.
How do they manage this?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

"Walter Wang [MSFT]" wrote:
Hi Dave,

Thank you for your update.

As long as we're using JavaScript to open the new browser window, we cannot
do much with the popup blocker.

Do you think using Cross-Page PostBack here will be helpful? For example:

<form id="form1" runat="server">
<asp:Button id="button1" runat="server" text="button"
OnClientClick="form1.target='_blank';"
PostbackUrl="~/Default2.aspx"
</asp:Button>
</form>

This will survive the popup blocker, but Default2.aspx will always open.
And we need to check if the first page's valid or not in Default2.aspx:

if (PreviousPage != null) {
if (PreviousPage.IsValid) {
...
}
}

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 16 '06 #8
Hi Dave,

I didn't see the popup on dell.com, do you mean that the popup gets opened
whenver you visit dell.com or when you click one of its hyperlinks? When
opening hyperlinks, if its target is set, it will open in another window.
But this is done without javascript, for example:

<a href="default2.aspx" target="_blank">here</a>

Also, most popup blockers can config some websites to be allowed to popup
new windows.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 17 '06 #9
That's it - it's a link (when you want to sign in).

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

"Walter Wang [MSFT]" wrote:
Hi Dave,

I didn't see the popup on dell.com, do you mean that the popup gets opened
whenver you visit dell.com or when you click one of its hyperlinks? When
opening hyperlinks, if its target is set, it will open in another window.
But this is done without javascript, for example:

<a href="default2.aspx" target="_blank">here</a>

Also, most popup blockers can config some websites to be allowed to popup
new windows.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 17 '06 #10
Thank you for your quick reply.

Do you need more discussion on this issue? Please feel free to post here.
Also, if you could provide more background and the requirement of your
project, maybe we could work out a better solution/workaround.

Have a nice day!

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 17 '06 #11
JT
Hi,

This is more of a question than a suggestion, and it's based on what I
might do in ASP. I don't know if it would work in ASP.NET.

Can you post back to the first page to do the validation, then if it's
valid create a second form with all of the values that were entered as
"hidden" types (if that's necessary and/or possible), and perform an
automatic submission with the PostbackUrl set the way it is recommended
here? Naturally, this validation and resubmission would occur in the
code filtered by an If (IsPostback). If you haven't already found a
solution, let me know what you think of this. I may need it in the
future.

Walter Wang [MSFT] wrote:
Hi Dave,

Thank you for your update.

As long as we're using JavaScript to open the new browser window, we cannot
do much with the popup blocker.

Do you think using Cross-Page PostBack here will be helpful? For example:

<form id="form1" runat="server">
<asp:Button id="button1" runat="server" text="button"
OnClientClick="form1.target='_blank';"
PostbackUrl="~/Default2.aspx"
</asp:Button>
</form>

This will survive the popup blocker, but Default2.aspx will always open.
And we need to check if the first page's valid or not in Default2.aspx:

if (PreviousPage != null) {
if (PreviousPage.IsValid) {
...
}
}

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Jul 18 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve Parks | last post by:
Using server-side code, how do I launch a new window? I have an ASP.Net application that uses a frameset, yet I have some (crystal) reports I want to view in a separate window. I can probably...
7
by: Paul | last post by:
Hi. I need to launch a windows application and then send keyboard event to this process to run certain commands. I've created a COM+ appplication to spawn and talk to the application which works...
1
by: Jacob | last post by:
I have several web apps that I want to redirect to a new page, but have that page open in a new browser window. The basic scenario is that I have a CrystalReport object that gets created and...
1
by: Sanjeev Mahajan via .NET 247 | last post by:
Hi All, I have a main page from which I am calling a popup page. Thepopup page has an editable grid and some other fields. There isalso a Save button on the popup page. When the user clicks...
3
by: Scott | last post by:
I wish to have a link on a page that launches a new browser before it loads the target link. The standard _new and _blank include the parent browser's cookies. Is there an alternative method that...
6
by: Ronald S. Cook | last post by:
How do I launch, say, Microsoft Word from within a C# Win app? Word should launch exterior to my app, of course. Is it easy to set size and position of where Word window will be placed? ...
1
by: Theadmin77 | last post by:
I have to validate s floats thru a function , but the validation have to be don with a string of 20 characters .... Any idea how to do thatvalidation floats? Any help will be very appreciated...
3
by: shyamg | last post by:
hi all, This javascript is working IE but not working in FIreFox, validating text fields. var dealerid = new keybEdit('abcdefghijklmnopqurstuvwxyz01234567890 ','Alpha-numeric input only.'); ...
1
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.