• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

.ascx file erro need some help

I create a .ascx file where I have a form, but when I load my .aspx page, on the page_load event I have setup some text to give some value to the forms in the .ascx file, but I'm getting this error msg.

Server Error in '/' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30390: '_ASP.babysitter_ascx.txtfname' is not accessible in this context because it is 'Protected'.

Source Error:

 

Line 7:              myConn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/database/babysitter.mdb") & ";")
Line 8:              myConn.Open()
Line 9:              babysitterform1.txtfname.Text = "Ennio"
Line 10:             
Line 11:             myConn.Close()
 
*******************************************************************************
And here is my .ASPX file




<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Register TagPrefix="bsf" TagName="babysitterform" src="babysitter.ascx" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Web.Security" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="vb"  runat="server">

Sub Page_Load( S As Object, E As EventArgs)
      If Not isPostBack Then
            babysitterform1.txtfname.Text = "Ennio"
            
      End If
End Sub

</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form runat="server">
<bsf:babysitterform ID="babysitterform1" runat="server" />
</form>
</body>
</html>
0
Ennio
Asked:
Ennio
  • 3
  • 2
1 Solution
 
DabasCommented:
Hi Ennio:
Have a look at the declaration of txtfnname in the code behind
Change its declaration to Public

Dabas
0
 
EnnioAuthor Commented:
Hi Dabas,
I was looking on my .ascx and I think I did something wrong, I don't have any declaretion... Here is the .ascx file

First Name: <asp:TextBox ID="txtfname" runat="server" /><br />
Last Name: <asp:TextBox ID="txtlname" runat="server" /><br />



How should I declare this?? I was look in a book, but it really doesn't show how to do that.
it just tell me do add some fields
0
 
DabasCommented:
Ennio:
NOT in the .ascx but in the .ascx.vb

Dabas
0
 
EnnioAuthor Commented:
hum.. I don't have one, this book really Su.....

Do you know where can I find some information about it?
What I should have on my .ascx.vb??
0
 
DabasCommented:
Ennio:
Just double click anywhere within your design screen

Dabas
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now