Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1100883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:57:07+00:00 2026-05-17T00:57:07+00:00

I get the feeling I am still using asp type scripting techniques in the

  • 0

I get the feeling I am still using asp type scripting techniques in the script below instead of proper asp.net scripting…

If this is true, how do I do the below the proper .net way?

<%@ Page Language="VB" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Text" %>

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

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

    <script runat="server">
        Dim objSQLConnection As SqlConnection
        Dim objSQLCommand As SqlCommand
        Dim objSQLDataReader As SqlDataReader
        Dim sbWidget As StringBuilder

        Dim strUser As String

        Function getWidgets() As String
            Dim strUserInitials() As String = Request.ServerVariables("LOGON_USER").Split(CChar("\"))
            strUser = LCase(Trim(strUserInitials(strUserInitials.GetUpperBound(0)))).ToString()

            sbWidget = New StringBuilder()

            objSQLConnection = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("connString"))

            For intColumn As Integer = 0 To 2
                objSQLCommand = New SqlCommand("select w.widget_id, w.widget_data " & _
                "from widgets w " & _
                "inner join widget_layout wy on w.widget_id = wy.widget_id " & _
                "where wy.column_id = " & intColumn & " " & _
                "and wy.user = '" & strUser & "' " & _
                "and w.inactive = 0", objSQLConnection)

                sbWidget.Append("<div class=""divWidgetColumn"" id=""divWidgetColumn_")
                sbWidget.Append(intColumn)
                sbWidget.Append(""">" & Environment.NewLine & vbTab & vbTab)

                objSQLCommand.Connection.Open()
                objSQLDataReader = objSQLCommand.ExecuteReader()

                While objSQLDataReader.Read()
                    sbWidget.Append("<div class=""divWidget"" id=""divWidget_")
                    sbWidget.Append(objSQLDataReader("widget_id"))
                    sbWidget.Append(""">" & Environment.NewLine)

                    sbWidget.Append("<div class=""divWidgetHeader"" id=""divWidgetHeader_")
                    sbWidget.Append(objSQLDataReader("widget_id"))
                    sbWidget.Append(""">")
                    sbWidget.Append("header goes here")
                    sbWidget.Append("</div>" & Environment.NewLine)

                    sbWidget.Append("<div class=""divWidgetSubHeader"" id=""divWidgetSubHeader_")
                    sbWidget.Append(objSQLDataReader("widget_id"))
                    sbWidget.Append(""">")
                    sbWidget.Append("sub header goes here")
                    sbWidget.Append("</div>" & Environment.NewLine)

                    sbWidget.Append("<div class=""divWidgetContent"" id=""divWidgetContent_")
                    sbWidget.Append(objSQLDataReader("widget_id"))
                    sbWidget.Append(""">")
                    sbWidget.Append("content goes here")
                    sbWidget.Append("</div>" & Environment.NewLine)

                    sbWidget.Append("<div class=""divWidgetFooter"" id=""divWidgetFooter_")
                    sbWidget.Append(objSQLDataReader("widget_id"))
                    sbWidget.Append(""">")
                    sbWidget.Append("footer goes here")
                    sbWidget.Append("</div>" & Environment.NewLine)

                    sbWidget.Append("</div>" & Environment.NewLine)
                End While

                sbWidget.Append("</div>" & Environment.NewLine)

                objSQLDataReader.Close()
                objSQLCommand.Connection.Close()
            Next intColumn

            Return sbWidget.ToString
        End Function
    </script>
    </head>

    <body>
        <div class="divWidgets">
            <%=getWidgets()%>
        </div>
    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:57:08+00:00Added an answer on May 17, 2026 at 12:57 am

    There is no one “proper” way. However, if you want to make a clean break from ASP classic and ASP.NET tag soup, I suggest you investigate ASP.NET MVC. For an example of really clean presentation layer code, check out the Razor and Spark view engines.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a masterpage in my ASP.NET MVC project. This masterpage expects some ViewData
After researching various hosts, I still get the feeling that it is somewhat impossible
I'm completely lost on what could be causing this. I have an ASP.Net MVC
I am attempting to write truly RESTful web services over HTTP using ASP.NET MVC
I get the feeling I'm missing something obvious, but I'm new to all of
I wish to get a quick feeling for how much copy and paste coding
I have built an ASP.NET MVC app some time ago, and after a few
We have moved from Archiva to Nexus and are still using Maven 2. We
After significant bit of searching around, I am still feeling quite clueless as to
I have a feeling that this should really not be all that difficult, yet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.