Solved

ASP.NET Context Sensitive Help from the database

Posted on 2009-04-04
4
190 Views
Last Modified: 2012-05-06
I am having problems getting the application documented in this url to work when the help content is stored in a database:

http://aspnet.4guysfromrolla.com/articles/082306-1.aspx

I have attached my code snippet.

Thank you



<%@ Page Language="VB" AutoEventWireup="false" CodeFile="AnotherDemo.aspx.vb" Inherits="AnotherDemo" %>

----- AnotherDemo.aspx

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>Another Context-Sensitive Help Demo</title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

               

    </div>

    <div>

        <br />

                         

        <asp:image ID="budget" runat="server" imageurl="images/common/question.gif" />        

        </div>

    </form>

</body>

</html>
 

----- AnotherDemo.aspx.vb

Partial Class AnotherDemo

    Inherits ContextSensitiveHelp
 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        AddContextSensitiveHelp(budget, "LongHelp", "generalhelp.aspx?cname=budget", True, 20, 5, 400, 300)

    End Sub

End Class
 

========= generalhelp.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="GeneralHelp.aspx.vb" Inherits="HelpFiles_GeneralHelp" %>
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <link href="HelpFile.css" rel="stylesheet" type="text/css" />

    <title>General Help</title>

</head>

<body>

    <h1>General Help</h1>    

    <p><asp:Image runat="server" ImageAlign="Right" ImageUrl="~/Images/bookCover.jpg" ID="MyBookCoverImage" BorderColor="Black" BorderWidth="1px" BorderStyle="Solid" Width="100" Height="128" /></p>

    <asp:DataList ID="dtlgalleries"

   BorderStyle="Solid" 

   BorderWidth="1px"  

   runat="server" 

   PagerStyle-Visible="False">

                <ItemTemplate>                                   

                    <%# Eval("Help_Content") %>">                                

                </ItemTemplate>

                <ItemStyle VerticalAlign="Top" />

            </asp:DataList>  

            <asp:SqlDataSource ID="SMGRWEB_DataSource" runat="server"

    ConnectionString="<%$ ConnectionStrings:SITEdbConnectString %>" providername = "<%$ connectionstrings:SITEdbConnectString.ProviderName  %>"

    SelectCommand="dbo.P_SMGRWEB_WEBSITE_Show_Help_Content" SelectCommandType="StoredProcedure">

    <SelectParameters>

        <asp:Parameter Name="ControlName" Type="string" />

    </SelectParameters>

</asp:SqlDataSource> 
 

</body>

</html>
 

========= generalhelp.aspx.vb

Partial Class HelpFiles_GeneralHelp

    Inherits System.Web.UI.Page
 
 

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
 
 

        SMGRWEB_DataSource.SelectParameters("ControlName").DefaultValue = "budget" 'request.querystring("cname")

    End Sub
 

End Class
 

---- DB
 

CREATE PROCEDURE [dbo].[P_SMGRWEB_WEBSITE_Show_Help_Content]

(

 @ControlName VARCHAR(50)=NULL

)

AS

 

SET NOCOUNT ON
 

SELECT Help_Content FROM dbo.context_help

WHERE ControlName = @ControlName
 

SET NOCOUNT OFF

GO

Open in new window

0
Comment
Question by:DeMyu
  • 2
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24072352
What problems are you having (exceptions, incorrect results, ...)?
0
 

Author Comment

by:DeMyu
ID: 24072959
The generalhelp.aspx is not displaying the content from the database when passed the value of a querystring.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 24077066
If you are using a QueryString value as a parameter value for an SqlDataSource, then you should define a different parameter type.

Example:


asp:SqlDataSource ID="ID" runat="server" ConnectionString="connectionString"

    ProviderName="providerName"

    SelectCommand="SELECT [ProductID], [ProductName], [UnitPrice] FROM [Products] WHERE ([CategoryID] = ?)">

    <SelectParameters>

        <asp:QueryStringParameter Type="Int32" 

            Name="CategoryID" 

            QueryStringField="CategoryID" />

    </SelectParameters>

</asp:SqlDataSource> 

Open in new window

0
 

Author Comment

by:DeMyu
ID: 24079320
TheLearnedOne,

Thank you! That resolved my problem plus the datasourceid was not declared in the datalist declaration. <asp:DataList ID="dtlgalleries"
    DataSourceID="SMGRWEB_DataSource"

Thank you again.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

910 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now