Adding parameter to the url from a UserControl

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kjell Arne

    Adding parameter to the url from a UserControl

    Hi,

    How do one add parameters to a URL from a UserControl?

    My problem is that I want to set a unique value to the webpage when the
    page loads. This value I will use as a identifier for that session
    (user). I'm certain it's a simple solution for this. But I have not been
    able to locate it yet.

    Usually in the old days, I would just generate input hidden tags in the
    form tag to hold this data...

    I would appreciate greatly for any pointers on this issue.

    - Kjell Arne

  • Ignacio Machin

    #2
    Re: Adding parameter to the url from a UserControl

    Hi,

    I really do not understand what you are trying to do, but anyway this is
    what you can do.
    You can declare a "hidden" control in several ways, if you are going to use
    it only in the server side then any ASP.NET control with the Visible
    property to false will not show in the page and it will accesible in the
    server side.
    if you are planning in using it in the client as well then you can use the
    HtmlInputHidden control in the same way that you use other control.

    Now a tip that I do not why is not more know, you can declare ANY control in
    the HTML as accessable from the server side, all you have to do is put in
    the tag runat="server" and then in the page you can declare that control as
    of type HtmlGenericCont rol . One example, let's say that you want to set the
    page's title dinamically, this is what you do:
    in the HTML page instead of:
    <title>listreco rds</title>
    you use:
    <title runat="server" id="pagetag">li strecords</title>

    then in the code behind you declare the control as:
    protected System.Web.UI.H tmlControls.Htm lGenericControl pagetag;

    and set it like :
    pagetag.InnerTe xt = "Set from code";


    Hope this help,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation

    "Kjell Arne" <savuud@atc.no_ yiha|spam> wrote in message
    news:3f5f5e3f$1 @news.broadpark .no...[color=blue]
    > Hi,
    >
    > How do one add parameters to a URL from a UserControl?
    >
    > My problem is that I want to set a unique value to the webpage when the
    > page loads. This value I will use as a identifier for that session
    > (user). I'm certain it's a simple solution for this. But I have not been
    > able to locate it yet.
    >
    > Usually in the old days, I would just generate input hidden tags in the
    > form tag to hold this data...
    >
    > I would appreciate greatly for any pointers on this issue.
    >
    > - Kjell Arne
    >[/color]


    Comment

    • Kjell Arne

      #3
      Re: Adding parameter to the url from a UserControl

      Hi.

      Well, my problem is that I am working on a webpage where I do not have
      access to anything but my own UserControl project.

      When the webpage loads, I want to write a unique identifier string that
      will be placed somewhere(?!) in the webpage, so I can retrieve it when
      the user sends post data to the server. That way I can register that id
      in the database and make sure that he does not register again with that
      session key.

      I've been told that I might be able to add parametres to the url in the
      browser?! (I cannot see how that is possible though, but I'm new to C# so..)


      - Kjell Arne

      [color=blue]
      > Hi,
      >
      > I really do not understand what you are trying to do, but anyway this is
      > what you can do.
      > You can declare a "hidden" control in several ways, if you are going to use
      > it only in the server side then any ASP.NET control with the Visible
      > property to false will not show in the page and it will accesible in the
      > server side.
      > if you are planning in using it in the client as well then you can use the
      > HtmlInputHidden control in the same way that you use other control.
      >
      > Now a tip that I do not why is not more know, you can declare ANY control in
      > the HTML as accessable from the server side, all you have to do is put in
      > the tag runat="server" and then in the page you can declare that control as
      > of type HtmlGenericCont rol . One example, let's say that you want to set the
      > page's title dinamically, this is what you do:
      > in the HTML page instead of:
      > <title>listreco rds</title>
      > you use:
      > <title runat="server" id="pagetag">li strecords</title>
      >
      > then in the code behind you declare the control as:
      > protected System.Web.UI.H tmlControls.Htm lGenericControl pagetag;
      >
      > and set it like :
      > pagetag.InnerTe xt = "Set from code";
      >
      >
      > Hope this help,
      >[/color]

      Comment

      • Ignacio Machin

        #4
        Re: Adding parameter to the url from a UserControl

        Hi again,

        So in other words you are programming the control and you do not control
        when/where this control will be used, right?
        If that is so, then I think that you do not need to put a string in the page
        you can generate this id when the cnotrol is build the first time, then it
        will be kept using the state. you can make this property public if you need
        so.


        Hope this help,

        --
        Ignacio Machin,
        ignacio.machin AT dot.state.fl.us
        Florida Department Of Transportation

        "Kjell Arne" <savuud@atc.no_ yiha|spam> wrote in message
        news:3f5f9d64$1 @news.broadpark .no...[color=blue]
        > Hi.
        >
        > Well, my problem is that I am working on a webpage where I do not have
        > access to anything but my own UserControl project.
        >
        > When the webpage loads, I want to write a unique identifier string that
        > will be placed somewhere(?!) in the webpage, so I can retrieve it when
        > the user sends post data to the server. That way I can register that id
        > in the database and make sure that he does not register again with that
        > session key.
        >
        > I've been told that I might be able to add parametres to the url in the
        > browser?! (I cannot see how that is possible though, but I'm new to C#[/color]
        so..)[color=blue]
        >
        >
        > - Kjell Arne
        >
        >[color=green]
        > > Hi,
        > >
        > > I really do not understand what you are trying to do, but anyway this[/color][/color]
        is[color=blue][color=green]
        > > what you can do.
        > > You can declare a "hidden" control in several ways, if you are going to[/color][/color]
        use[color=blue][color=green]
        > > it only in the server side then any ASP.NET control with the Visible
        > > property to false will not show in the page and it will accesible in the
        > > server side.
        > > if you are planning in using it in the client as well then you can use[/color][/color]
        the[color=blue][color=green]
        > > HtmlInputHidden control in the same way that you use other control.
        > >
        > > Now a tip that I do not why is not more know, you can declare ANY[/color][/color]
        control in[color=blue][color=green]
        > > the HTML as accessable from the server side, all you have to do is put[/color][/color]
        in[color=blue][color=green]
        > > the tag runat="server" and then in the page you can declare that control[/color][/color]
        as[color=blue][color=green]
        > > of type HtmlGenericCont rol . One example, let's say that you want to set[/color][/color]
        the[color=blue][color=green]
        > > page's title dinamically, this is what you do:
        > > in the HTML page instead of:
        > > <title>listreco rds</title>
        > > you use:
        > > <title runat="server" id="pagetag">li strecords</title>
        > >
        > > then in the code behind you declare the control as:
        > > protected System.Web.UI.H tmlControls.Htm lGenericControl pagetag;
        > >
        > > and set it like :
        > > pagetag.InnerTe xt = "Set from code";
        > >
        > >
        > > Hope this help,
        > >[/color]
        >[/color]


        Comment

        • Kjell Arne

          #5
          Re: Adding parameter to the url from a UserControl

          Hi..

          And thanks you for your help. Do you think you can give me an example of
          doing this? I do not understand what you mean with "You can generate
          this id and it will be kept using the state".

          So how do I generate this id? And what is a state? Are you refering to
          VIEWSTATE?

          - Kjell Arne
          [color=blue]
          > Hi again,
          >
          > So in other words you are programming the control and you do not control
          > when/where this control will be used, right?
          > If that is so, then I think that you do not need to put a string in the page
          > you can generate this id when the cnotrol is build the first time, then it
          > will be kept using the state. you can make this property public if you need
          > so.
          >
          >
          > Hope this help,
          >[/color]

          Comment

          Working...