Access ASP.NET Form or Control Values from One Page in Another Page

Access ASP.NET Form or Control Values from One Page in Another Page

Passing submitted values from a form on one page to another page for further processing is a common need in web and intranet applications. There are many ways to meet that need, such as using QueryString or Session variables. However, another?often more convenient?technique is to use the Server.Transfer() method.

Server.Transfer() transfers control to another web form—completely on the server, without a client-side redirect. Server.Transfer requires two parameters: (1) the name of the Web Form to which you want to pass control and (2) the Boolean value that determines whether ASP.NET should preserve or discard the current form state when it executes the new form. As you probably expect, to pass form values from one Web Form to another, set the second parameter to True.

The following code transfers control from a submitted form to a destination page.

Server.Transfer("destination.aspx", True)

In the preceding code, destination.aspx is the name of the page to which control is transferred, and the Boolean value True indicates that ASP.NET should preserve the current form state in the destination page.

Now, suppose the original form contained TextBox control with an ID of TextBox1. You can now access the value of that control in destination.aspx. For example, the following line would print out the value of the TextBox control:


Note that you must set the EnableViewStateMac page property for the destination page to False for this to work.

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as