How to Reference HTML Meta Tag in a Stored Procedure or Insert Query

  • Hello All,

    I am working on an ASP.NET website that serves up numerous content pages. The site owner wants users to rate the content through the use of an ASP.NET RadioButtonList. However, the content is static. He has a meta tag referencing the contentid, but doesn't want the content served up through dynamic data or through a stored procedure. However, he does want the votes for each content page tallied in SQL Server votes table.

    Questioin: What TSQL syntax would I use to reference the HTML meta tag on the content page?

    Thanks,

    Sid

  • It doesn't really work that way. You don't 'read' objects like that from SQL Server, you use the .NET page to send the data to the SQL Server and then store it there. You don't have to have dynamic content on the pages to pull this off, it can all be static, but you do need to add the piece to update the database when someone votes.

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • Hi Seth,

    Thanks for your reply. To confirm, I need to insert data into SQL Server from my website. The data to be inserted will be the article ID and the radiobutton.selectedvalue. What syntax would I use either in VB or TSQL to obtain the article ID from the HTML meta tag's content attribute?

    Thanks,

    Sid

  • Sid whenever I've done anything like this, I've always just added a hidden input to the form of the page that contains the article Id you'd be looking for;

    then it would be available in the postback of the page.

    it'd be much easier to add that, and populate it's value, than anything else. All that would occur before any code behind updates data to SQL server, right?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • just for fun, here is some inline javascript example, where i'm getting the meta tag "Description"'s value. i'm just doing an alert(), but you could have the button to submit the value to a page that stores the value; or put the smae code in the click event of a radio, whichever is good for you.

    does that help? then the same code could be included dynamically to all your static pages.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>

    <head>

    <title> New Document </title>

    <meta name="Generator" content="EditPlus">

    <meta name="Author" content="">

    <meta name="Keywords" content="">

    <meta name="Description" content="bananas">

    </head>

    <body>

    <input type="submit" onclick="var description;var metas = document.getElementsByTagName('meta');for (var x=0,y=metas.length; x<y; x++) { if (metas[x].name.toLowerCase() == 'description') { description = metas[x]; }}alert(description.content); // output content of description ">

    </body>

    </html>

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Hi Lowell,

    Thanks for both replies. I like your suggestion to use a hidden field control. In our case, this adds a bit more maintenance as the static content is moved from one content page to another, depending on vote popularity, the hidden field control value will need to be updated to the correct article ID. For example, let's say article ID 1 starts off on content page 1. However, article ID 5 gets many more votes, and is moved from content page 5 to content page 1. Is it correct to assume that we would need to change the hidden fields on content pages 1 and 5 to reflect the swap in article IDs?

    Thanks,

    Sid

  • By "moved", you mean manually deleted and hard coded into the other page?

    The hidden values need to match the values you want sent to the DB.

    Can you give an actual example? (Dummy data is fine)

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • Yes, the client wants the articles manually moved from one content page to another, depending on the number of votes each article receives. Articles with higher votes will be placed in the first several content pages.

    Anonymous website users must start on the landing page and can only move to the next content page after casting a vote for the article on the landing page. Thus, the only way to move to subsequent content pages is by casting a vote for the article on the landing page. Members (authenticated users) can traverse the entire set of content pages and are not required to vote.

    I've tried to propose a more dynamc solution than moving articles manually. However, my client is stuck in ASP.NET 2.0 and does not see the need to move to a dynamic data solution. I know the current solution is very clunky, but am trying to make the best of things 🙂

  • looks like we need a bit more info; Can we go to the web site and see what we are talking about?

    i'm assuming the ArticleId is unique to the content; so a simple web site might have 5 "pages", each with ArticleId 1 thru 5, right?

    the "votes" might be used to dynamically determine the order of those content pages in some menu, but there would never be any changing of the ArticleID, i would think.

    it's really confusing when you say the content is static.

    are the pages static .html files, or database driven .aspx files, or a blend of both(static .aspx files?)

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lowell (4/29/2010)


    looks like we need a bit more info; Can we go to the web site and see what we are talking about?

    i'm assuming the ArticleId is unique to the content; so a simple web site might have 5 "pages", each with ArticleId 1 thru 5, right?

    the "votes" might be used to dynamically determine the order of those content pages in some menu, but there would never be any changing of the ArticleID, i would think.

    it's really confusing when you say the content is static.

    are the pages static .html files, or database driven .aspx files, or a blend of both(static .aspx files?)

    Hi Lowell,

    Sorry for the confusion. Unfortunately, the site isn't live yet but rather just saved on my local machine. The content will be served up on .aspx files with naming convention 0001.aspx, 0002.aspx etc. 0001.aspx will be the landing page and will contain the article that has the most votes. If the article on 0002.aspx receives more votes than the article on 0001.aspx, then the content of 0002.aspx will be manually moved to 0001.aspx, along with the article ID hidden field whose value will remain constant (article ID=2 must stay the same regardless of which content page it resides so that voting remains intact.

    Please let me know if this makes sense, and/or if you see any opportunities to improve our logic/workflow.

    Thanks,

    Sid

  • You could probably improve it by actually making it dynamic =). Did they give you a reason they don't want data driven pages?

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

  • This client is stuck on ASP.NET 2.0, unwilling to consider 3.5/dynamic data because he feels that 2.0 can do the job. I'm afraid it will be a maintenance nightmare especially as he adds more content pages/articles.

  • Are you adverse to copying the same page over and over again?

    it'd be pretty simple to have some page look at it's own name, and provide the content dynamically, based on the votes and it's own page number;

    some crappy peudocode that probably will not reflect the idea:

    pagename: 0001.aspx

    --code on page gets something like

    SELECT * FROM (

    select row_number() over (ORDER BY NUMVOTES DESC) AS RW,ArticleId,ArticleContent,ArticleMetadata,* FROM ALLArticles)

    WHERE RW = [int of this pages name: 0001]

    --this might be the highest rated, article #5 in our example

    [insert article 5 from recordset above]

    --so page 1 gets the highest voted article, a copy of the same page, named 0002 gets it and it's matching article, etc.

    Hi Lowell,

    Sorry for the confusion. Unfortunately, the site isn't live yet but rather just saved on my local machine. The content will be served up on .aspx files with naming convention 0001.aspx, 0002.aspx etc. 0001.aspx will be the landing page and will contain the article that has the most votes. If the article on 0002.aspx receives more votes than the article on 0001.aspx, then the content of 0002.aspx will be manually moved to 0001.aspx, along with the article ID hidden field whose value will remain constant (article ID=2 must stay the same regardless of which content page it resides so that voting remains intact.

    Please let me know if this makes sense, and/or if you see any opportunities to improve our logic/workflow.

    Thanks,

    Sid[/quote]

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lowell (4/29/2010)


    Are you adverse to copying the same page over and over again?

    it'd be pretty simple to have some page look at it's own name, and provide the content dynamically, based on the votes and it's own page number;

    some crappy peudocode that probably will not reflect the idea:

    pagename: 0001.aspx

    --code on page gets something like

    SELECT * FROM (

    select row_number() over (ORDER BY NUMVOTES DESC) AS RW,ArticleId,ArticleContent,ArticleMetadata,* FROM ALLArticles)

    WHERE RW = [int of this pages name: 0001]

    --this might be the highest rated, article #5 in our example

    [insert article 5 from recordset above]

    --so page 1 gets the highest voted article, a copy of the same page, named 0002 gets it and it's matching article, etc.

    Hi Lowell,

    Sorry for the confusion. Unfortunately, the site isn't live yet but rather just saved on my local machine. The content will be served up on .aspx files with naming convention 0001.aspx, 0002.aspx etc. 0001.aspx will be the landing page and will contain the article that has the most votes. If the article on 0002.aspx receives more votes than the article on 0001.aspx, then the content of 0002.aspx will be manually moved to 0001.aspx, along with the article ID hidden field whose value will remain constant (article ID=2 must stay the same regardless of which content page it resides so that voting remains intact.

    Please let me know if this makes sense, and/or if you see any opportunities to improve our logic/workflow.

    Thanks,

    Sid

    [/quote]

    I think I'm starting to bring this into focus 🙂

    So, serve up the article dynamically via SQL query where 0001.aspx calls query such as select the article ID with the highest votes (max?) and output article content on 0001.aspx. If that's the case, what kind of SQL syntax would be used to get the 2nd to nth articles loaded in pages 0002.aspx through 000n.aspx ?

    Thanks much!

  • Sid Childers (4/29/2010)


    This client is stuck on ASP.NET 2.0, unwilling to consider 3.5/dynamic data because he feels that 2.0 can do the job. I'm afraid it will be a maintenance nightmare especially as he adds more content pages/articles.

    This doesn't make any sense to me. Nothing about 2.0 bars dynamic data. You could make dynamic pages with classic ASP. Maybe I'm missing something?

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic. Login to reply