Go Premium for a chance to win a PS4. Enter to Win

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
?
380 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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

885 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