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

x
?
Solved

Returning a simple link from a C# code behind page to the default.aspx page

Posted on 2011-03-03
4
Medium Priority
?
379 Views
Last Modified: 2012-08-14
I have a very simple web app, if you want to call it that, that I have to make for a third party vendor.  They have sent us a .dll.  I have it loaded into my project fine.  I need to reference it on the page_load event retreive an encrypted link and return that link to the default.aspx page.  Can someone help me with this.  Below is what I have thus far.
The URL control on my default.aspx page
-----------------------------
<asp:HyperLink ID="HyperLink1" runat="server">Click Here</asp:HyperLink>

from the code behind page
-----------------------------
using HC.Ope.Security;

namespace SSOorgChart
{
    public partial class _Default : System.Web.UI.Page
    {
        
        protected string Page_Load(object sender, EventArgs e)
        {

 
                //OPEEncrypter.EncryptData("mpatton", "123412341234134");
                string keyToken = "aXsDKUI98ILKi";
                string userId = "userid";
                string hyperLink = OPEEncrypter.EncryptData(userId, keyToken);

                return HyperLink1.NavigateUrl;

        }
    }
}

Open in new window

0
Comment
Question by:jmpatton
[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
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 35027325
If Hyperlink1 is the control on your page and the variable "hyperLink" contains the url you want to link to, then you just need to change:
return HyperLink1.NavigateUrl;

Open in new window

To:
HyperLink1.NavigateUrl = hyperLink;

Open in new window

0
 

Author Comment

by:jmpatton
ID: 35027358
The page_load event gets an error saying that not all paths return a value
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35027426
Page_Load is an event and doesn't return anything (event handlers always return void).

So instead of:
protected string Page_Load(object sender, EventArgs e)

Open in new window

It should be declared as:
protected void Page_Load(object sender, EventArgs e)

Open in new window

0
 

Author Closing Comment

by:jmpatton
ID: 35027658
Thanks for the help
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

704 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