To use queryString or not to use QueryString

Last post 05-16-2008 11:08 AM by Dollarjunkie. 6 replies.

Sort Posts:

  • To use queryString or not to use QueryString

    05-15-2008, 10:42 PM
    • Participant
      1,153 point Participant
    • Dollarjunkie
    • Member since 01-28-2007, 3:18 AM
    • Posts 854

    I am working on a project that requires loading and unloading user controls. To decide what to load or unload, I need to check two parameters. Problem is currently, I use Request.Querystring parameters to maintain those now and I was wondering if there is a better way to do that that even when the user clicks to refresh the page or tries to hack it, the code behaves in the manner it is supposed to, as in, based on user’s permission, the right action occurs and parameters passed, the right actions occur. Thanks in advance

    .Net Web/Software Engineer
  • Re: To use queryString or not to use QueryString

    05-15-2008, 11:25 PM
    • Participant
      1,183 point Participant
    • chandana
    • Member since 11-17-2006, 6:28 AM
    • Sri Lanka
    • Posts 305

    I'v not clear 100% of your question. but I think you asking whether request.querystring usage. The thing is when you use it others can see what are the parameters. That was happen even you encording url. So it depend on your requirment.for example if you pass username and password as parameter of querystring, that shows in addressbar and anybody can see it. but if you pass page number or search word (like serchengine) it is not a problem because it's not a problem.

    But in asp .net you have many options to pass parameters without use querystring.

    Chandana
  • Re: To use queryString or not to use QueryString

    05-15-2008, 11:41 PM
    • Participant
      1,153 point Participant
    • Dollarjunkie
    • Member since 01-28-2007, 3:18 AM
    • Posts 854

    So to keep code clean and professional, what would you use instead?? I am not too crazy about using Session variables or viewstate as I try to consider cases where session may be disabled or viewstate is turned off by mistake or something happens, say in firefox that causes it not to work as I would expect. But maybe all this is just me being paranoid. How would you handle this yourself?

    .Net Web/Software Engineer
  • Re: To use queryString or not to use QueryString

    05-16-2008, 12:20 AM
    • Participant
      1,183 point Participant
    • chandana
    • Member since 11-17-2006, 6:28 AM
    • Sri Lanka
    • Posts 305

    Actually I use view state to keep my all variable and object. Normally I put my all variables in a class and keep its object in view state and pass it as object through the pages. I think that’s better because I have over 300 variables in my single page. So then I can access my variables in next page. And also I do not use session variables to keep my variables because after some times the variables are cleared. And I personally think session variables are heavy for the system.

    Chandana
  • Re: To use queryString or not to use QueryString

    05-16-2008, 12:45 AM
    • Participant
      1,153 point Participant
    • Dollarjunkie
    • Member since 01-28-2007, 3:18 AM
    • Posts 854

    You mention that you use  a class to persist your variables. Can you please give me an idea of what you mean here. I mean sample code to give me an idea of what I can use in my case to do this?

    .Net Web/Software Engineer
  • Re: To use queryString or not to use QueryString

    05-16-2008, 1:16 AM
    • Participant
      1,183 point Participant
    • chandana
    • Member since 11-17-2006, 6:28 AM
    • Sri Lanka
    • Posts 305

    normally you want to do someway to pass variables between pages. to do that you have to create properties in your source page.

     

    example

    private int age;
    private string name;

     public int Age
     {
      get { return age;}
      set { age = value;}
     }
     

     public string Name
     {
      get { return name;}
      set { name = value;}
     }


    so you can get that property from next page. But in my case I define seperate class to keep both values. and i define that above properties in my class not axpx.cs page.So then I want to create and instance of that class and assign the properties to the class.and create single properties in aspx.cs page

    something like

    public MyClass MyClassObject

     {
      get { return myObject;}
      
     }


     Then I can handle the class (for example i can keep that class object in view state.insted of keeping variable in view state.)

    Chandana
  • Re: To use queryString or not to use QueryString

    05-16-2008, 11:08 AM
    • Participant
      1,153 point Participant
    • Dollarjunkie
    • Member since 01-28-2007, 3:18 AM
    • Posts 854

    Thinking along the lines of saving PageMode in ViewState. I just ran into a problem that I was hoping you could help me out with, How do I change this Object which is a property in the parent Page from the child Control. Basically, How do I reset the PageStatus Object which happens to belong to the UserControl's Parent Page, note that the userControl is loaded dynamically and not already on the page at firstload. How do I access the property information when I create the UserControl Object and how do I change it from the usercontrol when I am done with it. Below is the way I currently add my UserControl to my page.

    Private Sub TransactionLoader()

    Dim Display As Control = Me.LoadControl("~/Controls/TransactionBox.ascx")

    Display.ID = "TransactionBx"

    Me.SmartArea.Controls.Add(Display)

    End Sub

    .Net Web/Software Engineer
Page 1 of 1 (7 items)