473,804 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

submit form and redirection

alexjimenez
6 New Member
Hi, i am newbie in ASP

I try to redirect this form after submit to another page....what should i do?

Strings of form :

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" Debug="False" %>
  2. <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
  3. <%@ import Namespace="System.Web.Mail" %>
  4. <script runat="server">
  5.  
  6.     public void Page_Load() {
  7.       if (!IsPostBack)
  8.             content_form.Visible = true ;
  9.       else  {
  10.             content_result.Visible = true ;
  11.             content_form.Visible = false ;
  12.            }
  13.  
  14.     }
  15.  
  16.     void submit_click(object sender, ImageClickEventArgs e)
  17.           {
  18.             content_form.Visible = false ;
  19.             MailMessage msg = new MailMessage();
  20.             string recipient = "ajimenez@yahoo.com" ;
  21.  
  22.  
  23.  
  24.             msg.To = recipient ;
  25.             msg.Subject = "Kaba Web Site E-Plex Software reg (Access Control)" ;
  26.             msg.BodyFormat = MailFormat.Html ;
  27.  
  28.  
  29.             string message = "Please process as required. Thank You. <br>"  ;
  30.             message += "----------------------------------------------------------- <br><br>";
  31.            // message += "Reason you are contacting us?" + type_of_info.SelectedValue +" <br><br>" ;
  32.             message += "Name: " + firstname.Text +  " <br><br><br>" ;
  33.             message += "Company: "  + companyname.Text + " <br>" ;
  34.             if( title.SelectedItem.Value != "" )
  35.                 message += "Title : " + title.SelectedItem.Value.ToString() + " <br><br><br><br>";
  36.  
  37.             message += "Email : " + email.Text + " <br>" ;
  38.  
  39.             message += "City : " + city.Text + " <br>" ;
  40.             message += "State/Province : " + state_province.SelectedItem.Value + " <br> ";
  41.             if ( zip.Text != "" )
  42.                 message += "Zip/Postal Code: " + zip.Text + " <br> ";
  43.             if( phone.Text != "" )
  44.                 message += "Phone : " + phone.Text + " <br>";
  45.             if( fax.Text != "" )
  46.                 message += "Fax : " + fax.Text + " <br>";
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.             String yes_wants_more_information_on_kaa = Request.Form["yes_wants_more_information_on_kaa"];
  55.             String yes_mailinglist = Request.Form["yes_mailinglist"];
  56.  
  57.             message += "<b>Wants this (if listed): </b><br>";
  58.  
  59.              if (yes_wants_more_information_on_kaa != "")
  60.              message += yes_wants_more_information_on_kaa + "<br>";
  61.  
  62.             if (yes_mailinglist != "")
  63.              message += yes_mailinglist + "<br>";
  64.  
  65.  
  66.  
  67.             if( comments.Text != "" )
  68.                 message += "Additional details/comments: <br>" ;
  69.                 message += "<p class=\"content_site\" >" +  comments.Text + " </p><br>" ;
  70.  
  71.  
  72.             msg.From = email.Text;
  73.             msg.Body = message ;
  74.             SmtpMail.SmtpServer="10.254.250.48" ;
  75.             SmtpMail.Send(msg) ;
  76.  
  77.  
  78. // *** NEED TO REDIRECT WITH SPECIAL CODE?
  79. // Response.redirect "http://www.yahoo.com"
  80.             content_result.Text = "";
  81.  
  82.  
  83.             content_result.Visible = true ;
  84.           }
  85.  
  86. </script>


Code to submit :

Expand|Select|Wrap|Line Numbers
  1. <asp:ImageButton id="submit" onclick="submit_click" runat="server" AlternateText="SUBMIT" ImageAlign="left" ImageUrl="/common/submit.gif"></asp:ImageButton>
Dec 23 '08 #1
7 2289
Frinavale
9,735 Recognized Expert Moderator Expert
In the code that you've posted, you're sending an email once you've clicked a link button on your page...and then you want to redirect the user to another page.

What is the problem with using Response.Redire ct()?
What do you mean by: "I want to redirect with special code"?
What is this "special code" supposed to do?

-Frinny
Dec 23 '08 #2
alexjimenez
6 New Member
I put ResponseRedirec t as in :


# content_result. Text = "";
#
#
# content_result. Visible = true ;
# Response.redire ct "http://www.yahoo.com"
And this does not work, it wont redirect :( i dont know how to do a redirection after Submit.
Dec 23 '08 #3
Frinavale
9,735 Recognized Expert Moderator Expert
I really don't know why this would be working for you?
Where are you redirected to?

I have tested your code (minus the email sending part) and it works fine:

I added a link button to the page:
Expand|Select|Wrap|Line Numbers
  1.  <asp:LinkButton ID="doRedirect" runat="server" Text="Redirect To Yahoo"></asp:LinkButton>
  2.  
I redirect the user to Yahoo.com when the button is clicked:
Expand|Select|Wrap|Line Numbers
  1.    Private Sub doRedirect_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles doRedirect.Click
  2.         Response.Redirect("http://yahoo.com", True)
  3.     End Sub
  4.  
Note that I'm supplying a "True" parameter to the Response.Redire ct() method. This indicates that the page should no longer be processed after the user has been redirected...th is avoids any Tread.Abortion exceptions.

Maybe if you uncomment the code responsible for redirecting the user.....it might work?

-Frinny
Dec 23 '08 #4
alexjimenez
6 New Member
Not working :( ... i really dont understand

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1002: ; expected

Source Error:

Line 82: content_result. Visible = true ;
Line 83:
Line 84: Private Sub doRedirect_Clic k(ByVal sender As Object, ByVal e As System.EventArg s) Handles doRedirect.Clic k
Line 85: Response.Redire ct("http://yahoo.com", True)
Line 86: End Sub
Dec 23 '08 #5
Curtis Rutland
3,256 Recognized Expert Specialist
OK, Frinny was just giving you an example of using Response.Redire ct....and in her example she is using VB.NET, not C# like you are.

In the code you provided you are using it incorrectly.
Response.redire ct "http://www.yahoo.com"
this is incorrect. In C# you have to use parenthesis around method parameters, and end every statement with a semicolon (;). Also, C# is case-sensitive: Response.Redire ct is different than Response.redire ct.

Put this code in at the point you want to redirect:
Expand|Select|Wrap|Line Numbers
  1. Response.Redirect("http://www.bytes.com");
And change the bytes URL to wherever you need it to be.

Also note that the code after you redirect is pointless, since you will be taken to another page. You don't need to change anything on the page once you leave.
Dec 23 '08 #6
alexjimenez
6 New Member
THANK YOU ALL *IT WORKS WITH Code provided by insertAlias Moderator, i wasnt sure it was c# and i dont know nothing about ASP or .Net or C# ...this was super confusing for me


Thanks alot ! to all of you

BYTES.COM Rocks ! this is Great ! wow you programmers rocks! i wish i had your brain transplanted into mine with all your syntax knowledge ;)
Dec 23 '08 #7
Curtis Rutland
3,256 Recognized Expert Specialist
Glad to help, and always happy to get the feedback. Feel free to come back any time =D
Dec 23 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2881
by: Don | last post by:
I have a need to simulate the submission of an html-like <form> on the server, and was wondering if anyone knew of something out there that could do that. Thanks for your help, Don
3
5001
by: Martin Nadoll | last post by:
Hello i have a form, where my users can choose a postal code and a city to see a table result page with only entries of their choice. this results have to be shown in a new window : var firstLink = unescape(firstURL.cfm'); var secondLink = unescape(secondURL.cfm'); var thirdLink = unescape(thirdURL.cfm');
15
6584
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and the buttons. The problem is when I post a form to itself, the Enter key will not submit the form, it only clears the contents of the text box. The only way I can submit is to click the submit button. Here is a simplified version of my code that I...
8
3376
by: horos | last post by:
hey all, Ok, a related question to my previous one on data dumpers for postscript. In the process of putting a form together, I'm using a lot of placeholder variables that I really don't care about in the submitted action. I'd therefore like to get rid of them by doing something like:
2
12492
by: Hongyu | last post by:
I am trying to implement a simple JavaScript of redirecting my window to a new URL upon clicking a submit button. This is an easy task except when I have to put an input type='submit' in front of the onClick command. It always commits the CGI action, and skip the URL redirect part. The example code is below <form action=mycgi.pl> <input type='submit' name=submit value='Submit' onClick="window.location.href='http://myserver.com'">...
5
8452
by: rjames.clarke | last post by:
I have the following. $result=mysql_query($sql); $nrows=mysql_num_rows($result); for ($i=0;$i<$nrows;$i++) { $row_array=mysql_fetch_row($result); echo "<form name='testform' action='ins_op.php' method='post'>"; lots of form stuff
6
4929
by: Rachet? | last post by:
I am getting a "The remote server returned an error: (400) Bad Request." error while trying to send data to an asp page. The puzzle is, if I paste the string I want to send on a browser address box, it just go fine. From the win form app also it go fine until I happen to send an xml formatted string as a value. But same go fine through the browser. Any help is greatly appreciated. My code looks like:
2
1356
by: Gregor Horvath | last post by:
Hi, As I am no expert web programmer I thought I'd better ask the experts if there is a simpler or better solution to my problem than the one I am thinking of. (using TurboGears) The problem ----------- I have a form. Ok. you can submit, validate it etc.
1
10828
by: gbezas | last post by:
Hi All, I have added an event handler to redirect form.submit() to a newSubmit() method that I have defined (which does some additional processing before submitting the form). Additionally I have defined the relavant function method in the code for details) The issue is that when Icall targetForm._submit() method from the newSubmit() function the page I get an 'Object doesn't support this property or method' error I am using IE...
0
9714
marktang
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...
0
9594
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,...
0
10350
jinu1996
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...
1
10351
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,...
0
10096
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 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...
1
7638
isladogs
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...
0
6866
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.