Solved

Using HyperLink to pass values based on code behind variables

Posted on 2010-11-23
2
475 Views
Last Modified: 2012-05-10
Hi All

I have a hyperlink that links to the same page itself.
<asp:HyperLink ID="hyprNextMonth" runat="server" NavigateUrl="~/Calendar.aspx?M=" + <%=theCalendarDate.AddMonths(-1) %> ImageUrl="images/arrow_right.gif"/>

I'm trying to pass the next month int  in the NavigateUrl but can't get the code right.
Is there a better way of posting back to the same form as in PostBackURL or viewstate if so please show me how.

Thanks
0
Comment
Question by:iftech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 34199417
It would easier to do what you want from code-behind by dynamically setting the NavigateUrl from code. If you want to do it in markup you could use:

   NavigateUrl='<%# "~/Calendar.aspx?M=" + theCalendarDate.AddMonths(-1) %>'

But if you did that you would have to call DataBind() on the hyperlink from code-behind anyway. Also the code will probably blow up as you have it anyway probably complaining about the format of the URL.
0
 

Author Closing Comment

by:iftech
ID: 34200053
I used code behind to set NavigationURL
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question