Question

I just need help with an ASP.net code for redirecting to an error page if the...

I just need help with an ASP.net code for redirecting to an error page if the user hasn't clicked the validation button.

Here is the code I have currently:

protected void Page_Load(object sender, EventArgs e)
    {

    }

protected void btnValidate1_Click(object sender, EventArgs e)
    {

// USER MUST CLICK THIS BUTTON FIRST TO SHOW AN OUTPUT FOR THE ibnInvoice_Click (image button).

// IF USER HASN'T CLICKED THIS YET AND THEY CLICKED THE ibnInvoice_Click (image button), IT MUST BE REDIRECTED TO AN ERROR PAGE

    }

protected void ibnInvoice_Click(object sender, ImageClickEventArgs e)
    { // WHAT SHOULD MY IF STATEMENT BE? INSERT CODE HERE PLS. HERE IS THE CODE I HAVE THAT DOESN'T WORK:

        if(!btnValidate1)

        { // OUTPUT IF btnValidate1 IS CLICKED
            mvwMain.SetActiveView(viwInvoice);

            ibnInvoice.ImageUrl = "images/oeInvoiceSelected.png";
            ibnOrderInfo.ImageUrl = "images/oeOrderInfo.png";
            ibnBillingDetails.ImageUrl = "images/oeBillingDetails.png";

        }
          else

          {
            Response.Redirect("http://www.thatlink.com/Classes/Public/Error.aspx"); // ERROR PAGE REDIRECTION
          }
    }

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new Web Application in asp.net with C# is created using Visual Studio 2017 with name "ASPNETWebApplication".This application contains a web page with name "Default.aspx".Below are the details of this page.

NOTE :INITIALLY ON THE PAGE HIDE THE INVOICE BUTTON AND ON BUTTON CLICK OF THE VALIDATE BUTTON SET VISIBILITY PROPERTY OF BUTTON TO TRUE, THIS MEANS SHOW THE BUTTON.

Default.aspx :

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ASPNETWebApplication.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="btnValidate1" runat="server" Text="Validate" OnClick="btnValidate1_Click" />
  
<br />
<br />
<br />
  
<asp:Button ID="ibnInvoice" runat="server" Text="Invoice" OnClick="ibnInvoice_Click" />
<br />
<br />
<br />
<asp:Label ID="lblHeader" runat="server" Text=""></asp:Label>
</form>
</body>
</html>

************************

Default.aspx.cs :

//namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//application namespace
namespace ASPNETWebApplication
{
public partial class Default : System.Web.UI.Page
{

//page load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)//if page is loading for first time
{
ibnInvoice.Visible = false;//hide invoice button
}
}

protected void btnValidate1_Click(object sender, EventArgs e)
{
lblHeader.Text = "Validate button clicked";//set message
//when validation button clicked show invoice button
ibnInvoice.Visible = true;
}

protected void ibnInvoice_Click(object sender, EventArgs e)
{
// OUTPUT IF btnValidate1 IS CLICKED
//mvwMain.SetActiveView(viwInvoice);
//ibnInvoice.ImageUrl = "images/oeInvoiceSelected.png";
//ibnOrderInfo.ImageUrl = "images/oeOrderInfo.png";
//ibnBillingDetails.ImageUrl = "images/oeBillingDetails.png";
//display message
lblHeader.Text = "Validation done";

}
}
}

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :Default.aspx

Screen 2 :Screen when validation button is clicked

Screen 3:Screen when invoice button is clicked

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
I just need help with an ASP.net code for redirecting to an error page if the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C# Temperature Converter Application: I have most of the application complete I just need only help...

    C# Temperature Converter Application: I have most of the application complete I just need only help with error messages. My instructor wants me to show four error messages inside an error message label (not a message box) and all of the error messages should appear inside error message label. The four error messages should appear when: 1: User enters data inside both Celsius and fahrenheit text boxes: “You should enter data in only one textbox. Press Clear to start over.”...

  • Hi everyone, For my Assignment I have to use C# in order to create a validation...

    Hi everyone, For my Assignment I have to use C# in order to create a validation form and include the following things to register and validate: Email Address, Username, Password, Retype Password, and a Submit Button. I have figured out some of the code for the Email Address validation: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Validation4 {     public partial class Form1 : Form     {        ...

  • I really need some help fixing a code error in Visual Basic I was wondering if...

    I really need some help fixing a code error in Visual Basic I was wondering if anyone could help fix the error that I'm about to provide in bold thanks so much! I'll also tell what the error is. Public Class MainForm Private Sub exitButton_Click(sender As Object, e As EventArgs) Handles exitButton.Click Me.Close() End Sub Dim img As Image = Image.FromFile("C:\Users\Pranesh\Pictures\11599264.jpg") house1PictureBox.Image = img house2PictureBox.Image = img house3PictureBox.Image = img house4PictureBox.Image = img house1PictureBox.Visible = False house2PictureBox.Visible = False house3PictureBox.Visible...

  • I need help with this problem in Visual Basic 2012: Write a program that allows the...

    I need help with this problem in Visual Basic 2012: Write a program that allows the user to specify two numbers and then adds, subtracts, multiplies, or divides them when the user clicks on the appropriate button. The output should give the type of arithmetic performed and the result. Whenever one of the numbers in an input text box is changed, the output text box should be cleared. Also, if the number 0 is entered into the second text box,...

  • C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have...

    C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have 2 Labels (each one of them assigned only to Celsius and Fahrenheit), 2 TextBoxes (each one of them assigned only to Celsius and Fahrenheit), only 1 Convert Button, 1 Clear Button, and 1 Exit Button. Also, 1 Error message label which will display the error messages. The application should only allow the user to enter the desired temperature just in one of the TextBoxes...

  • for Javascript, JQuery When the page is first opened a user will see the name field...

    for Javascript, JQuery When the page is first opened a user will see the name field and the three vacation images to the left of the page. The page should behave according to the following rules. 1. When a user's mouse pointer goes over any image, that image's border will change to be "outset 10px" and when the mouse pointer leaves that image it's border will change to "none". 2. When the user clicks a "Vacation" image on the left,...

  • Here is my code to insert data into a database. code: private void button2_Click(object sender, EventArgs...

    Here is my code to insert data into a database. code: private void button2_Click(object sender, EventArgs e) { //Insert Button string connString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source = C:\project\patientDB.accdb"; OleDbConnection connection = new OleDbConnection(connString); OleDbCommand cmd = connection.CreateCommand(); cmd.CommandText = "insert into Medical ([PatientID],[GeneralMedicalHistoryID],[Education] values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "' )"; connection.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Record Inserted"); connection.Close(); } However it says syntax error in INSERT statement when I try to add. What am...

  • Looking for some help here: Edit GetPhoneData to add more input validation by setting ranges for...

    Looking for some help here: Edit GetPhoneData to add more input validation by setting ranges for values Brands (Samsung, iPhone, Google) Models (Galaxy, Note, 8, X, Pixel) Price ($0.01-$2000) Include a comment about your addition, you can be creative, add components (or not), individualize this. Extra Credit (Samsung must be paired to Galaxy or Note) 2 points Below is the code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Cell_Phone_Test {...

  • What am I doing wrong? I get this error: "The name 'LoginPasswordUserControl' does not exist in...

    What am I doing wrong? I get this error: "The name 'LoginPasswordUserControl' does not exist in the current context" I have a user control, here is the code: using System.Windows.Forms; //Define the namespace to make the user control. //namespace to hold the application namespace LoginPasswordUser { //Define the class to make the user control.   //Class to define the control   public partial class LoginPasswordUserControl : UserControl { //Define the read-only properties to get the username and the password from the user...

  • Here is my skeleton code to this C# assignement I need to add a few things,...

    Here is my skeleton code to this C# assignement I need to add a few things, Change the the switch to If and Else-If statements (and test it is still working here) Add a third "Submit" button called SubmitButton In your If and Else-If add a condition if city is Honolulu and SubmitButton is checked. Display "Honolulu is the best place to be this time of year! I wish I was there!". Add comments, including header. HELP PLEASE ASAP public...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT