|
-
Oct 26th, 2009, 05:59 AM
#1
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
-
Oct 26th, 2009, 06:03 AM
#2
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
-
Oct 26th, 2009, 07:23 AM
#3
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
-
Oct 26th, 2009, 07:38 AM
#4
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
-
Oct 26th, 2009, 07:46 AM
#5
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
-
Oct 26th, 2009, 07:57 AM
#6
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
-
Oct 26th, 2009, 09:51 AM
#7
Hyperactive Member
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..
-
Oct 26th, 2009, 09:54 AM
#8
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
-
Oct 27th, 2009, 12:55 AM
#9
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
-
Oct 27th, 2009, 02:11 AM
#10
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
-
Oct 28th, 2009, 03:23 PM
#11
Fanatic Member
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).
-
Oct 29th, 2009, 12:41 AM
#12
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
-
Oct 29th, 2009, 02:36 AM
#13
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
-
Oct 29th, 2009, 03:45 AM
#14
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
-
Oct 29th, 2009, 05:14 AM
#15
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
-
Oct 29th, 2009, 05:40 AM
#16
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|