Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 11th, 2009, 03:28 PM
Registered User
 
Join Date: Aug 2009
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create hyperlinks

I need help with a simple glossary that I am currently working on.

I have a sql database with two tables
TermDB
Term_Id
Term

DefinitionDB
Def_Id
Definition
Term_Id

I have a search function and an accordion to display my data. Terms are being displayed in the header portion of the accordion and definitions are in the content section. So far everything is working.

My major problem now is cross referencing. For example, if there is a term in the definition, then that term would need to be converted into a hyperlink. When the user clicks on that term it would update the accordion and display the definition. How would I do that? I probably need to write a sql statement but I am not sure how.

Thanks a lot!

Last edited by lm111; August 11th, 2009 at 03:32 PM..
  #2 (permalink)  
Old August 11th, 2009, 04:53 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Quote:
if there is a term in the definition, then that term would need to be converted into a hyperlink
Why?? Why aren't the definitions simply hidden in the accordion?? What's the point of the <A> link?
  #3 (permalink)  
Old August 11th, 2009, 04:54 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

And do *ALL* terms have one or more definitions? Or are some terms undefined?
  #4 (permalink)  
Old August 11th, 2009, 10:23 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Guess I'm a little confused.

"If there is a term in the definition..."

What does this mean? Does this mean there are some definitions without terms? And if so, why? That doesn't make sense to me.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #5 (permalink)  
Old August 12th, 2009, 08:24 AM
Registered User
 
Join Date: Aug 2009
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry if I did not make myself clear. Here is an example.
Let's say I have a couple of terms and definitions and I use an accordion to display my data.

Term1 //displayed in the header section of my accordion
Here is the definition. //displayed in the content section of the accordion
Term2
Here is the definition but here is also a reference to Term1.


The user clicks on Term2 in the accordion and its definition displays. Since the definition for Term2 contains a reference to Term1 the user will need to be able to click on that link. Once clicked the accordion should update itself and display Term1 and its definition.

Thanks a lot!
  #6 (permalink)  
Old August 12th, 2009, 02:34 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

As far as the nuts and bolts of it, it would certainly take some fancy doings. But I think the basic underlying algorithm would be fairly straightforward.

In the method that retrieves the definition body, you would want to search the resulting string for occurences of a defined term. You would need to do this for each defined term, probably by looping through a collection of all the terms.

If an occurence is found, you'd build a corresponding hyperlink and replace the string occurence with it, then push it all to the page as HTML.

This would be a fairly intensive process, you would definitely want to cache everything and manage the cache as new terms are added, deleted, etc.

Good luck with it.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #7 (permalink)  
Old August 13th, 2009, 11:54 AM
Registered User
 
Join Date: Aug 2009
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your reply. I attached a few pieces of my code and was wondering if you could help me get started. I am still in the process of learning and I have been stuck with this problem for a while now and it's driving me crazy. Any idea on how to approach this through code would be greatly appreciated.


.aspx

<asp:TextBox ID="txtTerm" Tooltip="Search" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="SEARCH" OnClick="btnSearch_Click" />
<cc1:Accordion ID="acc1" runat="server" SuppressHeaderPostbacks="true" FadeTransitions="true" TransitionDuration="250" FramesPerSecond="40" RequireOpenedPane="false">

<HeaderTemplate><%# ((DataRow)Container.DataItem)["Term"] %> </HeaderTemplate>
<ContentTemplate><%# ((DataRow)Container.DataItem)["Definition"] %></ContentTemplate>
</cc1:Accordion>


Code behind file
################################################## ###################################
protected void btnSearch_Click(object sender, EventArgs e)
{


DataTable dtblGlossary = (DataTable)Cache["GlossaryToFilter"];
if (dtblGlossary == null)
{
dtblGlossary = GetInfoFromDB();
Cache["GlossaryToFilter"] = dtblGlossary;
}



string filter = String.Format("Term LIKE '{0}*'", txtTerm.Text);
DataRow[] rows = dtblGlossary.Select(filter, "Term");

// Bind to Accordion
acc1.SelectedIndex = 0;
acc1.DataSource = rows;
acc1.DataBind();


}


public static DataTable GetInfoFromDB()
{
string connectionString = WebConfigurationManager.ConnectionStrings["TermDefinition"].ConnectionString;
SqlDataAdapter dad = new SqlDataAdapter("SELECT Term, Definition FROM DB", connectionString);
DataTable dtblGlossary = new DataTable();
dad.Fill(dtblGlossary);
return dtblGlossary;

}

################################################## ######################################

Thank you so much.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
create links using XSL prashob_2 XSLT 7 February 18th, 2009 07:32 AM
automatically create new records scandalous Access VBA 3 February 27th, 2007 03:08 PM
Creating links from database results buckster Classic ASP Databases 1 February 1st, 2005 01:26 PM
How to Create Links to Word Document frm Reports sundarakshi Crystal Reports 0 November 6th, 2004 02:19 AM
Combo box that links records from two tables... takawera Access VBA 1 October 14th, 2003 05:39 PM



All times are GMT -4. The time now is 07:05 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.