locked
What is passing parameters?? RRS feed

  • Question

  • What is meant by passing parameters in c# and how to pass the parameters to different pages??
    Thursday, November 4, 2010 7:43 AM

Answers

  • www.forums.asp.net is the one you need to ask this question. Not here. c# specialits will be more available there.

    You can Pass Parameters to other pages by using Querystrings.  to send a query string, we will append  the data to the URL and call that page, in that page, we will read that querystring and get values.

    -- Passing value

    Response.Redirect("abc.aspx?Flag=" + mystr);

    -- To Read this value

    string = Request.QueryString["Flag"];

    There are some more mechanisms we can use to share data between pages. Sessions,Application. Read this below URL.

    http://msdn.microsoft.com/en-us/library/6c3yckfw.aspx

     

    • Proposed as answer by Pulin Zala Thursday, November 4, 2010 10:32 AM
    • Marked as answer by Kalman Toth Thursday, November 11, 2010 7:10 AM
    Thursday, November 4, 2010 8:04 AM

All replies

  • www.forums.asp.net is the one you need to ask this question. Not here. c# specialits will be more available there.

    You can Pass Parameters to other pages by using Querystrings.  to send a query string, we will append  the data to the URL and call that page, in that page, we will read that querystring and get values.

    -- Passing value

    Response.Redirect("abc.aspx?Flag=" + mystr);

    -- To Read this value

    string = Request.QueryString["Flag"];

    There are some more mechanisms we can use to share data between pages. Sessions,Application. Read this below URL.

    http://msdn.microsoft.com/en-us/library/6c3yckfw.aspx

     

    • Proposed as answer by Pulin Zala Thursday, November 4, 2010 10:32 AM
    • Marked as answer by Kalman Toth Thursday, November 11, 2010 7:10 AM
    Thursday, November 4, 2010 8:04 AM
  • Hello,

    With parameter in C# (Ado.Net) I guess you mean this: SqlCommand.Parameters Property

    But I don't know what you mean with "different pages".


    Olaf Helper ----------- * cogito ergo sum * errare humanum est * quote erat demonstrandum * Wenn ich denke, ist das ein Fehler und das beweise ich täglich http://olafhelper.over-blog.de
    Thursday, November 4, 2010 8:10 AM
  • Thanks for your reply but passing parameters and passing values are both the same??but if we use query string to pass parameters there will be a security risk isnt it? if i am not wrong we can use sessions to pass parameters or not.
    Saturday, November 6, 2010 7:07 AM
  • Passing parameters and passing values both are same.

    Yes. Its not advisable to pass sensitive parameters through querystring. We have an option of encoding and decoding. When we sending the parameter, we can encode and send. There in other page we can decode it.

    We can use Sessions also to share values between multiple pages. But each session object will take some space at server. Too many objects in session will take entire memory. So, its always advisable to remove the objects from session as soon as you don't need those objects.

    Saturday, November 6, 2010 7:13 AM