DarkWorlds
Technical User
Ok, well i know this may look like I posted up something similar a dar or two ago.
Well since no one can help me out on that, then I need to move on. This is yet another please wait. But I am having a problem getting the demo to work at all. I am hoping that someone can fill in the blanks for me.
Now I am running VS 2003 with asp.net 1.1 if it helps. I tried just to get it to run via VB and it wouldnt even go. So when I converted it over to c# it was a no go.
So help on this, or my past thread would be very helpfull. I am just trying to help out the user.
Well since no one can help me out on that, then I need to move on. This is yet another please wait. But I am having a problem getting the demo to work at all. I am hoping that someone can fill in the blanks for me.
Code:
<%@Page Language="VB" Debug="True" %>
<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.SqlClient" %>
<%@Import Namespace="System.Threading" %>
<script runat="server">
Sub Page_Load()
If Page.IsPostback Then
' user submitted page with customer ID
' create URL with query string for customer ID
' next page will not be a postback, so viewstate will be lost
Dim sRefreshURL As String = Request.Url.ToString() _
& "?custID=" & txtCustomer.Text
' use META REFRESH to start loading next page
mtaRefresh.Attributes.Add("http-equiv", "refresh")
mtaRefresh.Attributes.Add("content", "0;url=" & sRefreshURL)
' hide <form> section and show "wait" section
frmMain.Visible = False
divWait.Visible = True
Else
' get customer ID from query string
Dim sCustID As String = Request.QueryString("custID")
If sCustID > "" Then
' page is loading from META REFRESH element and
' so currently shows the "please wait" message
' a customer ID was provided so display results
divResult.Visible = True
' set URL for "Next Customer" hyperlink
lnkNext.NavigateUrl = Request.FilePath
' get data and bind to DataGrid in the page
FillDataGrid(sCustID)
Else
' either this is the first time the page has been
' loaded, or no customer ID was provided
' display controls to select customer
frmMain.Visible = True
End If
End If
End Sub
<%-------------------------------------------------------------%>
Sub FillDataGrid(sCustID As String)
Dim sSelect As String _
= "SELECT CustomerID, CompanyName, City, Country, Phone " _
& "FROM Customers WHERE CustomerID LIKE @CustomerID"
Dim sConnect As String _
= ConfigurationSettings.AppSettings("NorthwindSqlClientConnectString")
Dim oConnect As New SqlConnection(sConnect)
Try
' get DataReader for rows from Northwind Customers table
Dim oCommand As New SqlCommand(sSelect, oConnect)
oCommand.Parameters.Add("@CustomerID", sCustID & "%")
oConnect.Open()
dgrResult.DataSource = oCommand.ExecuteReader()
dgrResult.DataBind()
oConnect.Close()
lblResult.Text = "Results of your query for Customer ID '" _
& sCustID & "'"
' force current thread to sleep for 3 seconds
' to simulate complex code execution
Thread.Sleep(3000)
Catch oErr As Exception
oConnect.Close()
lblResult.Text = oErr.Message
End Try
End Sub
</script>
<!------------------------------------------------------------->
<!------------------------------------------------------------->
<html>
<head>
<!----- dynamically filled META REFRESH element ----->
<meta id="mtaRefresh" runat="server" />
<!-- #include file="../global/style.inc" -->
<title>Displaying a "Please Wait" Message</title>
</head>
<body>
<span class="heading">Displaying a "Please Wait" Message</span><hr />
<!----- form for selecting customer ----->
<form id="frmMain" Visible="False" runat="server">
Enter Customer ID:
<asp:Textbox id="txtCustomer" runat="server" />
<asp:Button id="btnSubmit" Text="Go" runat="server" />
</form>
<!----- "please wait" display ----->
<div id="divWait" Visible="False" runat="server">
<center>
<p> </p>
<p> </p>
<b>Searching, please wait...</b><p />
<p> </p>
<span id="spnError"></span>
<p> </p>
</center>
</div>
<!----- section for displaying results ----->
<div id="divResult" Visible="False" runat="server">
<b><asp:Label id="lblResult" runat="server" /></b><p />
<asp:DataGrid id="dgrResult" runat="server" /><p />
<asp:Hyperlink id="lnkNext" Text="New Customer" runat="server" />
</div>
<p />
<span class="cite">
Remember to edit the connection strings in web.config file
for the Northwind sample database.
</span>
<hr />
<!-- #include file="../global/viewsource.inc" -->
<!-- #include file="../global/footer.inc" -->
</body>
</html>
Now I am running VS 2003 with asp.net 1.1 if it helps. I tried just to get it to run via VB and it wouldnt even go. So when I converted it over to c# it was a no go.
So help on this, or my past thread would be very helpfull. I am just trying to help out the user.