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)
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
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
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
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 ?
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..
Re: HyperLink HTML PostBack
Hey Dana,
I am not sure that I follow exactly what your requirement here is:
Quote:
Can we create a hyperlink control in code behind and can get the HTML view of the control ?
What exactly do you mean?
Gary
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 ?
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
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).
Re: HyperLink HTML PostBack
Thanks for the reply. The thing is that the I need the CrossPage PostBack. Not the PostBack.
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
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
Re: HyperLink HTML PostBack
maybe you could use javascript to set a cookie with the values you need to retain across pages.
Re: HyperLink HTML PostBack
Let me check with my team