473,657 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Blank Web Page

Hello all, could someone explain why I'm getting a blank web page when I run
start my code in a web browser? Here is the code:
Imports System.Data.Sql Client
Imports System.Data
Public Class WebForm1
Inherits System.Web.UI.P age

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
'Create the data connection.
Dim sqlconnectConta ctMgmt As New SqlConnection _
("server=(local );database=Cont acts;Trusted_Co nnection=yes")
'Create a data adapter.
Dim sqladaptContact Mgmt As New _
SqlDataAdapter( "select * from Contacts", sqlconnectConta ctMgmt)
'Create a data set.
Dim dsContacts As New DataSet()
'Fill in the data set.
sqladaptContact Mgmt.Fill(dsCon tacts, "Contacts")
'Display the table in a data grid using data binding.
Dim DataGrid1 As New DataGrid()
DataGrid1.DataS ource = dsContacts.Tabl es("Contacts"). DefaultView
DataGrid1.DataB ind()

End Sub
End Class
Nov 19 '05 #1
1 1444
This line of code:

Dim DataGrid1 As New DataGrid()

is creating a new DataGrid which it goes on to bind the data to. Unfortunately,
if you just create a grid in this fashion it is not attached to the web form.
A web form has to 'know' about a DataGrid in order to display the grid, and
just creating a grid like this doesn't let the page know about the grid.

Are you using Visual Studio.NET? If so, you'll want to drag and drop a DataGrid
control onto the web form. Visual Studio will put a grid into the form and
give you a variable in the code behind to match. All you'll need to do then
is set the DataSource property and call DataBind (like you have below).

Making sense?

--
Scott
http://www.OdeToCode.com/blogs/scott/
Hello all, could someone explain why I'm getting a blank web page when
I run
start my code in a web browser? Here is the code:
Imports System.Data.Sql Client
Imports System.Data
Public Class WebForm1
Inherits System.Web.UI.P age
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
'Create the data connection.
Dim sqlconnectConta ctMgmt As New SqlConnection _
("server=(local );database=Cont acts;Trusted_Co nnection=yes")
'Create a data adapter.
Dim sqladaptContact Mgmt As New _
SqlDataAdapter( "select * from Contacts",
sqlconnectConta ctMgmt)
'Create a data set.
Dim dsContacts As New DataSet()
'Fill in the data set.
sqladaptContact Mgmt.Fill(dsCon tacts, "Contacts")
'Display the table in a data grid using data binding.
Dim DataGrid1 As New DataGrid()
DataGrid1.DataS ource =
dsContacts.Tabl es("Contacts"). DefaultView
DataGrid1.DataB ind()
End Sub

End Class

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5089
by: dmcconkey | last post by:
Hi folks, I have a client with four websites. Each site has a contact form that is identical. They all have "required" fields validated through a JavaScript onSubmit() function. Upon validation, post values go to a PHP processing page that adds values to a database and generates an email to someone in marketing. For three of these sites, we have no problem, but the fourth keeps sending in blank forms.
2
3292
by: Ravi | last post by:
I have a webpage(with a text field and a button) which prompts for a local file and attempts to load the file in the window if the user clicks on the button. The javascript code onClick event uses the location.href property to achieve the desired result. (This loaded page has some additional functionality which lets them upload the contents to the server.) This approach only seem to work for some computers and on others it is loading a...
2
1403
by: Michael | last post by:
All, I have a form send a variable to another page. Based on the variable the page will show a different image. I.E. <form METHOD="POST" ACTION="http://mysite.com/photo.htm"> <input type="hidden" name="MODEL" value="europe"> <input type="submit" class="submitphoto" value="View Europe"> </form>
14
2618
by: charlie_M | last post by:
Is there a way to blank the screen in a FORM's onsubmit=... to blank the screen for the user?? I asked this before and got a way to blank a table by id with "document.getElementById('tabid').style.display='none';" in the onclick event and setting the encapsulating table's ID to 'tabid'. I was wondering if this or some other similar approach that could possibly be planted globally in my pages in the onsubmit validation
6
5533
by: Melissa | last post by:
Does anyone have a generic procedure for adding blank lines to reports like Sales details, PO details and/or Orders details. The procedure would need to count the number of line items, determine the remaining page to fill and print blank lines with the same number of fields as the line items. In addition, if there were a long list of line items that carried over to a second and possibly more pages, to print blank lines at the last page. The...
4
10951
by: Nhmiller | last post by:
Access seems to always generate a second page, which is blank, to my one page report. How do I delete the second page? Thanks. Neil Cat Paintings At Carol Wilson Gallery http://www.carolwilsongallery.com
6
4694
by: noway | last post by:
I have greated a report and have included a page break in it. The report breaks were it is supposed to but then it creates a blank page between the two pages. Since this report will print out approx 20 pages (without the blank pages) it is large waste of paper. I have tested the report by setting the data source so that only one page will print and all the data fits on page. I have checked all the printing parameter, set the print magins...
3
9151
by: Wayne | last post by:
I have a report containing 2 subreports. The subreports each contain a chart. The whole thing easily fits on one page but a second blank page is consistently being generated. This has nothing to do with the page width being too large because it isn't, and the second blank page displays the report header and footer. I can reduce the depth of the subreports so that they only take up one half of the first page's depth, but the second...
1
2264
by: siomay87 | last post by:
please help i have a problem in the ms access reporting, my report have: page header, detail, page footer and report footer In listing "detail section", the number of line is depend on the data source I mean long or short in detail section is vary. The problem is, when the detail is more than 25 line it will give blank area below the 25th line in page 1, and page 2 continue with report footer. This blank area in page is cause by...
4
3089
by: sid | last post by:
"about:blank" oepns new browser window I am writing a webpage that will run on other machines that I may or may not know about. My page is framed where frame1 controls the content of frame2. What I have found is that if the page in Frame2 fails to load and I get an error page. when I detect an error page I want to set frame2.location.href = "about:blank" and then write a temp error page until the server becomes available again. The...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8516
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.