kaurm

kaurm

  • NA
  • 12
  • 13.9k

how to navigate/redirect hyperlinks on asp.net

Jan 15 2014 8:49 PM
I have a webpage where a student or teacher can check their information.  The way it works is that first they enter in their ID and the webpage evaluates the ID and finds information related to that ID.  Than the student or teacher can click on their ID and than it supposed to check if it's a teacher or student depending on that it should navigate to the appropriate page.  I was thinking that can be done in Page_Load method.  
 
The difference between the Student ID and Teacher ID is that StudentID is less than 6 character and TeacherID is longer than 6 character.  
Currently in the Default.aspx page it has this which only goes to the TeacherData.aspx page but it is not linked to the StudentData.aspx page. 
 <ItemTemplate>
<table>
<tr>
<td>ID</td>
<td>&nbsp;<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "~/Identification/TeacherData.aspx?ID="+Eval("ID") %>'
Text='<%# Eval("UserID") %>'></asp:HyperLink></td>


Above part Evaluates the ID and finds the information from the sql table. 
public partial class _Default : System.Web.UI.Page 
{

   protected void Page_Load(object sender, EventArgs e) 
   { 
   if (!IsCallback
     { //if it's student than go to this hyperlink instead // HyperLink1.NavigateUrl
   }
}
How do I write the function to change the hyperlink if it's a student? Please help, thank you in advance.
 

Answers (5)