Detecting concurrency errors after updating data (VB)

Thursday, July 30th, 2009

<%@ Page Language="VB" %>

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

<script runat="server">
    Protected Sub SqlDataSource1_Updated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs)
        If (e.AffectedRows > 0) Then
            Message.Text = "The record has been updated"
        Else
            Message.Text = "Possible concurrency violation"
        End If
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:SqlDataSource ID="SqlDataSource1" 
                           Runat="server" 
                           SelectCommand="SELECT * FROM [Customers] WHERE ([CustomerID] = @CustomerID)"
                           ConnectionString="<%$ ConnectionStrings:AppConnectionString1 %>"
                           DataSourceMode="DataSet"
                           ConflictDetection="CompareAllValues" 
                           OnUpdated="SqlDataSource1_Updated">
            <SelectParameters>
                <asp:QueryStringParameter Name="CustomerID" 
                                          QueryStringField="id" 
                                          Type="String">
                </asp:QueryStringParameter>
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:Label ID="Message" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>

 

Using CreateUserWizard

Sunday, July 26th, 2009

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Create Account</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CreateUserWizard ContinueDestinationPageUrl="CreateAccount.aspx" ID="CreateUserWizard1"
            runat="server">
            <WizardSteps>
                <asp:CreateUserWizardStep runat="server" Title="Sign Up for Your New Account">
                </asp:CreateUserWizardStep>
                <asp:CompleteWizardStep runat="server" Title="Complete">
                </asp:CompleteWizardStep>
            </WizardSteps>
        </asp:CreateUserWizard>
    
    </div>
    </form>
</body>
</html>

 

Showing ServerVariable values via the ServerVariables Collection in ASP.NET

Monday, July 20th, 2009

<%@ Page Language="vb" %>
<html>
   <head>
      <title>Showing ServerVariable values via the ServerVariables Collection in ASP.NET</title>
   </head>
<body>

<%
    Dim VirPath, PhysPath, BasePath As String
    Dim BoolCross As Boolean = True
    
    VirPath = "/QuickStart"
    BasePath = ""
    
    Response.Write(Request.MapPath(VirPath, BasePath, BoolCross))
%>

</body>
</html>
           
       

HTML Input Radio Button: get selected item (VB.net)

Tuesday, July 14th, 2009

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)

End Sub
Sub SubmitBtn_Click(Source As Object, E as EventArgs)
    MyMessage.InnerHTML = ""
    If radBreakfast.Checked = True Then
        MyMessage.InnerHTML = "You selected " _
            & "breakfast.<BR>"
    ElseIf radLunch.Checked = True Then
        MyMessage.InnerHTML = "You selected " _
            & "lunch.<BR>"
    Else
        MyMessage.InnerHTML = "You selected " _
            & "dinner.<BR>"
    End If
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Allowing Input through the HTMLInputRadioButton Control</TITLE>
</HEAD>
<BODY>
<form runat="server">
<Span
    id="MyMessage"
    runat=server
>
</Span>    
<BR>
Which is your favorite meal?  
<BR>
<Input
    id="radBreakfast"
    runat="server"
    type="radio"
    Checked
    name="Meal"
/>
Breakfast 
<BR>
<Input
    id="radLunch"
    runat="server"
    type="radio"
    name="Meal"
/>
Lunch
<BR>
<Input
    id="radDinner"
    runat="server"
    type="radio"
    name="Meal"
/>
Dinner
<BR>
<button 
    id="Button1"
    runat="server"
    onserverclick="SubmitBtn_Click" 
>
Submit
</button>
</Form>
</BODY>
</HTML>
           
       

mobile:TextView (VB.net)

Saturday, July 11th, 2009

<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" Language="vb" %>
<HEAD>
    <title>Mobile Control Example</title>
    <script runat="server">
        Protected Sub List1_Click(source As Object, e As ListCommandEventArgs)
            Select Case e.ListItem.Value
                Case 2
                    ActiveForm = Form2
                Case 3
                    ActiveForm = Form3
                Case 4
                    ActiveForm = Form4
            End Select
        End Sub
        Protected Sub Command1_Click(source As Object, e As EventArgs)
            If Not SelectionList1.Selection.Value = "4" Then
                Label1.Text = "You run as Admin too often!"
            Else
                Label1.Text = "Excellent!"
            End If
        End Sub
</script>
</HEAD>
<body xmlns:mobile="http://schemas.microsoft.com/Mobile/WebForm">
    <h1>Mobile Control Example</h1>
    <mobile:Form id="Form1" Runat="server">
        <mobile:Label id="Label2" runat="server">Choose a sample:</mobile:Label>
        <mobile:List id="List1" OnItemCommand="List1_Click" runat="server" Decoration="Numbered">
            <Item Value="2" Text="SelectionList Sample"></Item>
            <Item Value="3" Text="PhoneCall Sample"></Item>
            <Item Value="4" Text="TextView Sample"></Item>
        </mobile:List>
    </mobile:Form>
    <mobile:Form id="Form2" runat="server">
        <mobile:Label id="Label1" runat="server">How often do you run Windows as Admin?</mobile:Label>
        <mobile:SelectionList id="SelectionList1" runat="server">
            <Item Value="0" Text="Always"></Item>
            <Item Value="1" Text="Often"></Item>
            <Item Value="2" Text="Sometimes"></Item>
            <Item Value="3" Text="Rarely"></Item>
            <Item Value="4" Text="Never"></Item>
        </mobile:SelectionList>
        <mobile:Command id="Command1" OnClick="Command1_Click" runat="server">Submit</mobile:Command>
    </mobile:Form>
    <mobile:Form id="Form3" runat="server">
        <mobile:PhoneCall id="PhoneCall1" runat="server" PhoneNumber="(000)555-1234" AlternateUrl="http://www.java2s.com">Call Mom</mobile:PhoneCall>
    </mobile:Form>
    <mobile:Form id="Form4" runat="server">
        <mobile:TextView id="TextView1" runat="server" Wrapping="Wrap">mobile text view</mobile:TextView>
    </mobile:Form>
</body>