Results 1 to 16 of 16

Thread: HyperLink HTML PostBack

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Thumbs up HyperLink HTML PostBack

    Hi All,
    I came across a table creation code which uses html tags.
    Code:
    "<a class='gridlink' targe='_self' href = 'NamedZone.aspx?flag=I&lat=" & _
                            '           zoneLat & "&long=" & "</a>
    Now this navigates to another page. But I need to add one variable from JavaScript to a hidden value.For this I need the request to hit the server and navigate to that page.

    I was just to trying to create one Hyperlink control using HTML. But not succeeded. Has any one any idea ?

    Thanks in Advance
    Please mark you thread resolved using the Thread Tools as shown

  2. #2

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: HyperLink HTML PostBack

    I did something like this. But it is not hitting server

    Code:
    url = Page.ClientScript.GetPostBackClientHyperlink(hlink, values)
                                collObject(loopCount, 1) = String.Format(Control, url, zoneAddress)
    Please mark you thread resolved using the Thread Tools as shown

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: HyperLink HTML PostBack

    Hey Dana,

    Do you know what the value is at the time that page is first rendered?

    Can you not add this at the time the page is first rendered, rather than first posting back to the server?

    Gary

  4. #4

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: HyperLink HTML PostBack

    I am setting the value using javascript. And I need to get this set text in the next page. As the text is done using Javascript. I am not getting in the other page
    Please mark you thread resolved using the Thread Tools as shown

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: HyperLink HTML PostBack

    Hey,

    Doh, I see what you are getting at.

    Yeah, so you need to put the JavaScript value into a HiddenField and then read this value on the server.

    Have a look at the following:

    http://www.bestechvideos.com/2009/04...de-information

    It should cover what you are trying to do.

    Gary

  6. #6

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: HyperLink HTML PostBack

    Let me see the vid. Mean time, I have a question. Can we create a hyperlink control in code behind and can get the HTML view of the control ?
    Please mark you thread resolved using the Thread Tools as shown

  7. #7
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Re: HyperLink HTML PostBack

    yes we can create hyperlink from the code behind but...

    an get the HTML view of the control...i didn't get this line..

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: HyperLink HTML PostBack

    Hey Dana,

    I am not sure that I follow exactly what your requirement here is:

    Can we create a hyperlink control in code behind and can get the HTML view of the control ?
    What exactly do you mean?

    Gary

  9. #9

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: HyperLink HTML PostBack

    Take this example.
    I am creating an HyperLink Control in code behind as
    Code:
    Dim hlink As New HyperLink
                hlink.NavigateUrl = "~Default.aspx"
    If the page is rendered in page the view source the page will be something like

    Code:
    "<a class='gridlink' href='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("""", """", 
    false, """", ""{0}"", false, true))'>{1}</a>"


    Can I get this source without rendering the page ?
    Please mark you thread resolved using the Thread Tools as shown

  10. #10
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: HyperLink HTML PostBack

    Hey,

    I thought that might be what you are getting at, but I wasn't sure.

    There are methods such as RenderContents and RenderControl that write the control into an HtmlTextWriter. In theory, I guess you could create a HtmlTextWriter, and then call ToString on that, but what I would like to know is why you would need to do this.

    Gary

  11. #11
    Fanatic Member
    Join Date
    Jun 2004
    Location
    All useless places
    Posts
    917

    Re: HyperLink HTML PostBack

    @danasegarane: I'm just trying to step back and answer your first post. If I get you right all you are trying to do is inject a postback option into the link.

    In that case I would modify the <a> tag like below:
    Code:
    hrefValue = "javascript:__doPostBack('" + Page.ClientID + "', 'myPostBack:../app/SubFolder/NewPage_" + myId.ToString()
                                            + ".aspx?myTypeID=" + myId + "&myNumber=" + currentDataRow["no"] + "');";
    hyperlinkHTML = @"<a href=""" + hrefValue + @""" target=""_self"">" + columnText + "</a>";
    And insert this HTML in a placeholder on the page (I did this for gridview).
    Then in the Page load event I have
    Code:
    if(!IsPostBack){
    //...do what you want
    }
    else
     {
           string eventArg = Request.Params.Get("__EVENTARGUMENT");
           if (eventArg.StartsWith("myPostBack:"))
           {
               //Do the Response.Redirect with hidden field.
            }
    }
    After composing this post it seems I may have got your post wrong (ignore this in that case).

  12. #12

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: HyperLink HTML PostBack

    Thanks for the reply. The thing is that the I need the CrossPage PostBack. Not the PostBack.
    Please mark you thread resolved using the Thread Tools as shown

  13. #13
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: HyperLink HTML PostBack

    Hey,

    Ok, I am getting lost again

    I thought I had a handle on this thread, but I think it is gone.

    Dana, can you describe exactly what you are trying to achieve, perhaps with an example?

    Gary

  14. #14

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: HyperLink HTML PostBack

    The thing is that I am fixing one application which uses user control and links it. For the Links inside the table they used the <a> tag instead of normal hyper link control.

    And my situation is that I have retain some selected values in the current page as the current page navigate to another and comes back here.

    Now the page should retain the values of some html(Not. Not server control) text box
    values.

    For that what I need is to set the value in JavaScript some where in hidden field and using the previous Page method get the hidden values and stored in session and while coming back check the session and populate the check boxes

    Hope I am clear now
    Please mark you thread resolved using the Thread Tools as shown

  15. #15
    Frenzied Member brin351's Avatar
    Join Date
    Mar 2007
    Location
    Land Down Under
    Posts
    1,293

    Re: HyperLink HTML PostBack

    maybe you could use javascript to set a cookie with the values you need to retain across pages.
    Last edited by brin351; Oct 29th, 2009 at 05:15 AM. Reason: spell check

  16. #16

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: HyperLink HTML PostBack

    Let me check with my team
    Please mark you thread resolved using the Thread Tools as shown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width