Solved

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

Posted on 2011-03-03
4
375 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 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

726 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