I have a form that I want to redirect to another page after clicking the submit button. It works well (please see the code below) except that it cancells my pop-up message, it goes the redirected page without showing the popup. Please help: - private void Submit_Click(object sender, System.EventArgs e)
-
{
-
if( filMyFile.PostedFile.ContentLength != 0 )
-
{
-
-
string strFilename;
-
strFilename = filMyFile.PostedFile.FileName;
-
strFilename = System.IO.Path.GetFileName(strFilename);
-
-
filMyFile.PostedFile.SaveAs(@"C:\Advert_images\"+strFilename);
-
}
-
else
-
{
-
// No file
-
-
-
}
-
-
-
string status;
-
string image_name;
-
image_name = filMyFile.PostedFile.FileName;
-
image_name = System.IO.Path.GetFileName(image_name);
-
status = "unverified";
-
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
-
SqlCommand cmd = new SqlCommand("Add_advert_new", con);
-
cmd.CommandType = CommandType.StoredProcedure;
-
con.Open();
-
cmd.Parameters.Add("@Title",SqlDbType.VarChar);
-
cmd.Parameters["@Title"].Value = txtTitle.Text;
-
cmd.Parameters.Add("@Expiry_date",SqlDbType.DateTime);
-
cmd.Parameters["@Expiry_date"].Value = Session["SelectedDate"].ToString();
-
cmd.Parameters.Add("@Description",SqlDbType.Text );
-
cmd.Parameters["@Description"].Value = txtDescr.Text;
-
cmd.Parameters.Add("@Added_by",SqlDbType.VarChar );
-
cmd.Parameters["@Added_by"].Value = Session["Name"].ToString();
-
cmd.Parameters.Add("@Surname",SqlDbType.VarChar );
-
cmd.Parameters["@Surname"].Value = Session["SName"].ToString();
-
cmd.Parameters.Add("@status",SqlDbType.VarChar );
-
cmd.Parameters["@status"].Value = status;
-
cmd.Parameters.Add("@image_name",SqlDbType.VarChar );
-
cmd.Parameters["@image_name"].Value = image_name;
-
-
cmd.ExecuteNonQuery();
-
con.Close();
-
- Response.Write(@"<script language='javascript'>alert('Advert has been uploaded but it will be verified by the webmaster fisrt before it can be displayed. Have a nice day!')</script>");
-
-
-
-
SmtpMail.SmtpServer = ConfigurationSettings.AppSettings["EmailServer"];
-
string strTo = "MicheleH@int.scm";
-
string strFrom = "webmaster@int.scm";
-
-
string strSubject = "New advert to be verified";
-
-
SmtpMail.Send(strFrom, strTo, strSubject,
-
"A new advert has been loaded, please click on the link http://jhb-ds-web1/scmnet/doc/verifyadverts.aspx to verify the advert.");
-
-
-
Response.Redirect("classifieds_1.aspx");
-
}
1 5921
The only reason I know that ASP.NET events take action first (higher priority), I maybe mistaken. To solve this problem you have to set both actions in the same priority so do the redirect using JavaScript instead of ASP.NET. - Response.Write(@"<script language='javascript'>alert('Advert has been uploaded but it will be verified by the webmaster fisrt before it can be displayed. Have a nice day!')</script>");
-
-
Response.Write(@"<script language='javascript'>window.location = 'http://www.google.com'</script>");
-
It should works fine if not please tell me.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: sentinel |
last post by:
Hi,
Wonder if anyone can help with this problem:
I am using an app with several pages, using a session to track vars
between the pages, and using an image map to re-direct back and
forwards between the pages.
The way I redirect is when the image map is clicked on, it posts to a
page called 'control.php' which passes the POST vars to the
|
by: Galina |
last post by:
Hello
I have 6 dependent list boxes on my ASP page:
Faculty;
Lecturer;
Course;
Course occurrence;
Group;
Week commencing date.
When faculty is selected, lists of lecturers and courses are
populated. When course is selected, lists of occurrences, groups and
|
by: John Lau |
last post by:
Hi,
Is there documentation that talks about the page lifecycle, the lifecycle of
controls on the page, and the rendering of inline code, in a single
document?
Thanks,
John
|
by: MooreSmnith |
last post by:
When I navigate to the next page using
Response.Rediect("MyNextPage.aspx") current page Page_Load event is called.
What I may wrongly understood is that post back will happen whenever there
is any server side event happens, resulting in Page_load event. Page_Load is
also happening when I navigate to the next page. That means Page_load will
always happen when I navigate to the next page. Please correct me If I have
totally misunderstood...
|
by: Oz |
last post by:
Hi
Using VS.NET 2003, Windows XP SP1,
We have a page which has been developed using ASP.NET. On it, is a button
which when clicked is supposed to add some data to a table. When the button
is selected, it causes the ServerClick event to be called twice.
Here's the code: You'll see that there are two grids on the page, and that
the function SetupDataGrid populates data to the two grid. There are also
| |
by: Tom wilson |
last post by:
I have created a very simple example that doesn't work. Form1
contains a textbox and a button:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Response.Redirect("login.aspx")
End Sub
Very simple. Forget what login.aspx does, it's just somewhere to
redirect to.
|
by: scottyman |
last post by:
I can't make this script work properly. I've gone as far as I can with
it and the rest is out of my ability. I can do some html editing but
I'm lost in the Java world. The script at the bottom of the html page
controls the form fields that are required. It doesn't function like
it's supposed to and I can leave all the fields blank and it still
submits the form. Also I can't get it to transfer the file in the
upload section. The file name...
|
by: Simon Benson |
last post by:
Probably a fairly simple problem but one that's been plaguing me for a
couple of days... can anyone help?
I have a classic ASP page with a number of text boxes which are updatable.
For convenience I want to add 'tabs' at the top of the page (like a card
index) as the data to be displayed is split into specific groups (client,
company, preferences, events).
How do I update any changes to the data and switch to a different page - at
|
by: sumeetmakkar |
last post by:
Hi all,
I am a begineer and working on a project. Facing trouble linking a submit buuton to a page of my choice.Script i am using is:
<SCRIPT language=JavaScript><!--
function validate(form) {
for (var i=0; i <form.elements.length; i++) {
if (form.elements.type == 'button') {
if (!form.elements.clicked) {
alert('Complete the 1st line checks!');
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |