ASP.NET VB - auto-mate/CheatSheetWiki GitHub Wiki

ASP Without Visual Studio

<%@ Page Language = "VB" Debug = "True" %>
<HTML>
<HEAD>
    <title>ASP Without Visual Studio ...</title>
</HEAD>
<BODY>

<%

Response.Write( "ASP Without Visual Studio ..." )
Dim MyServer as string
MyServer   = "EnterYourServerName"

%>

<%=
MyServer
%>

<xmp>
    Notes
    =====
    1. ASP Tags...
    % % - is for inline code (especially logic flow)
    %$ % - is for evaluating expressions (like resource variables)
    %@ % - is for Page directives, registering assemblies, importing namespaces, etc.
    %= % - is short-hand for Response.Write (discussed here)
    %# % - is used for data binding expressions.
    %: % - is short-hand for Response.Write(Server.HTMLEncode()) ASP.net 4.0+
    %#: % - is used for data binding expressions and is automatically HTMLEncoded.
    %-- --% - is for server-side comments

    2. Host on IIS

</xmp>


<form  runat=server>
  <!-- 
    Cant put these comments in asp tags
    NB Dim MyParam as string = "EnterYourParamValue" does not work if entered in the % section at the start of body...
   -->
  <asp:SqlDataSource ID="SqlDataSource" runat="server" ConnectionString="Data Source=EnterYourServerName;Initial Catalog=EnterYourDatabaseName;Persist Security Info=True;User ID=EnterYourUser;Password=EnterYourPassword;"  SelectCommand="EnterYourSQL">     
  </asp:SqlDataSource>
  <%
    Dim MyParam as string = "EnterYourParamValue"
    dim sql as string = ""EnterYourSQL... WHERE ["EnterYourFieldName"]='" & MyParam & "'" 
    SqlDataSource.SelectCommand=sql
  %>

  <asp:GridView EmptyDataText = "No Records Found" ShowHeaderWhenEmpty="True" ID="GridView1" runat="server"  AutoGenerateColumns="True" DataSourceID="SqlDataSource" ToolTip="TootlTip Data">      
  </asp:GridView>



  <!--  For Manual Columns set gridview option [AutoGenerateColumns="False"] and add like below between asp:GridView /asp:GridView tags
    <Columns>
      <asp:BoundField DataField="YourFieldName" HeaderText="YourFieldName" />      
    </Columns>  
  -->



</form>
<xmp>
Web.Config file only needed for this page if debugging via custom errors [NB also set Debug = "True" in Line 1 i.e.  Language Declaration] e.g.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>
</xmp>

</BODY>
</HTML>
⚠️ **GitHub.com Fallback** ⚠️