Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 191077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:18:38+00:00 2026-05-11T16:18:38+00:00

In ASP>Net using C#, I declared a variable as member of the class as

  • 0

In ASP>Net using C#, I declared a variable as member of the class as follows:

public class sales: System.Web.UI.Page
{
string type=null;
}

And i have an Image Button in my UI for which I’ve defined the event called

protected void ImageButton2_Click(object sender, ImageClickEventArgs e)

in this method, any value assigned to variable ‘type'(by any other method of the class) is not retained and only value null is being retrieved though I’ve assigned some value to ‘type’ somewhere inside the class…

What could be the problem that I cant access the assigned value????

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:18:38+00:00Added an answer on May 11, 2026 at 4:18 pm

    This is probably a result of the render pipeline. Remember, even though your event is being fired, the page and all variables are recreated with their default value. Create it as a property with at least a backing viewstate storage.

    public String Type 
    {
        get { return ViewState["Type"].ToString(); } 
        set { ViewState["Type"] = value; } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have few global methods declared in public class in my ASP.NET web application.
I am using Asp.net/C# ,, i have declared an integer array as follows public
(Was: ASP.Net codebehind not finding controls on the web page) I'm using VS 2008.
I am working on asp.net using c#. I have one master page with 3
I am trying to send an email in ASP.NET using system.net.mail the problem is
I'm using VS2010,C# to develop an automation site (ASP.NET web app) which may have
I'm using Resharper 6 and ASP.NET Web Methods and have an irritating warning in
I am using ASP.net in my project. I Declare a Variable btn_clik, tot at
I'm using VS2010,C# to develop my ASP.NET web app, sometimes I need to declare
I am using asp.net In my .cs page I am setting a value for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.