Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using HyperLink to pass values based on code behind variables

Posted on 2010-11-23
2
Medium Priority
?
479 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

715 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