Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

Hyperlink Text

$
0
0

Im making a website ( first time in visual studios) and its an online library. I have a book info page which shows more information about the book. The problem is that when i search for books how can i make it possible for the book to have a hyperlink to navigate towards the book info page. What i am doing right now is using a drop down list and i have a value assigned to each book(1-n) and have the person choose the number of the book and then click enter which navigates to the books more info page. I just want to be able to click on the title and navigate straight to it my other page( BookInfo.aspx).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BookStoreOnline
{
    
    
    public partial class WebForm2 : System.Web.UI.Page
    {
        private static string test;
        private static string testInfo;
        private static List<Book> resultList;
        private static List<Image> imageList;

protected void Page_Load(object sender, EventArgs e)
        {
            User.Text += (Session["UserName"]+""); 
        }

   protected void Button1_Click(object sender, EventArgs e)
        {
            // if box is filled
            // check criteria selected
            // initiate search based on criteria
            // display results

            if (SearchBox.Text != "")
            {
                resultList = new List<Book>();

   
                
                test = SearchCriteria.SelectedItem.Text;
                testInfo = SearchBox.Text;

                switch (test)
                {
                    case "ISBN":
                        resultList = ((Database)Session["Database"]).SearchISBN(testInfo);
                        break;
                    case "Title":
                        resultList = ((Database)Session["Database"]).SearchTitle(testInfo);
                        break;
                    case "Author":
                        resultList = ((Database)Session["Database"]).SearchAuthor(testInfo);
                        break;
                    case "Semester":
                        resultList = ((Database)Session["Database"]).SearchSemester(testInfo);
                        break;
                    case "Course":
                        resultList = ((Database)Session["Database"]).SearchCourse(testInfo);
                        break;
                    case "Section":
                        resultList = ((Database)Session["Database"]).SearchSection(testInfo);
                        break;
                    case "Professor":
                        resultList = ((Database)Session["Database"]).SearchProfessor(testInfo);
                        break;
                    case "CRN":
                        resultList = ((Database)Session["Database"]).SearchCRN(testInfo);
                        break;
                }

     if (resultList.Count == 0)
                {
             NoResults.Text = "No results were found.";
                }
                else
                {
              Results.Text = "";
                }
           for (int i = 0; i < resultList.Count; i++)
                {
                   int j = i + 1;

          ListItem bookIndex = new ListItem(j.ToString());

  Results.Text += "<pre>" + j + ". Title: " + resultList[i].Title + "<br>" + "Author: " + resultList[i].Author + "<br><br>" + "</pre>";
 MoreInfoIndex.Items.Add(bookIndex); 
    //MoreInfoIndex.Items.Add(bookIndex); is what i am using to navigate to the book info page                    
                }
            }
        }

        protected void MoreInfoButton_Click(object sender, EventArgs e)
        {
            int k = Convert.ToInt32(MoreInfoIndex.SelectedItem.Text) - 1;
            
            Session.Add("Book", resultList[k]);
            //Session["Book"] = resultList[k];
            Response.Redirect("BookInfo.aspx");
        }
    }
}

 


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>