473,725 Members | 2,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User Control... HELP???

Can someone please help....

I'm having major issues with a user control I'm tring to create!

I an trying to execute a sub called UploadData() from a user control which I
managed to do but for some reason I keep getting the error:

Exception Details: System.NullRefe renceException: Object reference not set
to an instance of an object.

Source Error:
Line 114: Sub UploadData()
Line 115: 'Dim ImageFile As System.Web.UI.H tmlControls.Htm lInputFile
Line 116: Dim imgstream As Stream = ImageFile.Poste dFile.InputStre am
Line 117: Dim imgdata(ImageFi le.PostedFile.C ontentLength) As Byte
Line 118: imgstream.Read( imgdata, 0,
ImageFile.Poste dFile.ContentLe ngth)

Error is on line 116...

I know that the sub works because if I put it staight into the aspx page it
works fine but as soon as I put the sub into the User Control it seems to
stop working as ImageFile.Poste dFile.InputStre am = nothing...

Can someone please please HELP.... Why does this happen???

Thanks

ASPX PAGE...

Imports System.Data.Sql Client
Imports System.Data
Imports System.IO

Public Class binUpload
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
Protected WithEvents Menu1 As skmMenu.Menu
Protected WithEvents phHeader As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phHeaderMenu As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phFooter As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phQuickLinks As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phRefresh As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phBody As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phUploader As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phWait As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phResults As System.Web.UI.W ebControls.Plac eHolder
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

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

phBody.Controls .Add(New LiteralControl( "<body bottomMargin=" &
Chr(34) & "0" & Chr(34) & "leftMargin =" & Chr(34) & "0" & Chr(34) &
"topMargin= " & Chr(34) & "0" & Chr(34) & "rightMargi n=" & Chr(34) & "0" &
Chr(34) & "runat=" & Chr(34) & "server" & Chr(34) & ">"))
Dim UploadCnt As Control =
LoadControl("../binFileUpload/UploadCnt.ascx" )
phWait.Controls .Clear()
phResults.Contr ols.Clear()
phUploader.Cont rols.Add(Upload Cnt)

If Page.IsPostBack Then

' user submitted file to be uploaded
' create URL with query string to confirm file upload
' next page will not be a postback, so viewstate will be lost
Dim sRefreshURL As String = Request.Url.ToS tring() &
"?Upload=Tr ue"

If Request.Browser .Browser = "IE" Then
phBody.Controls .Clear()
phBody.Controls .Add(New LiteralControl( "<body onload=" &
Chr(34) & "loadTarget (" & Chr(39) & sRefreshURL & Chr(39) & ")" & Chr(59) &
Chr(34) & " bottomMargin=" & Chr(34) & "0" & Chr(34) & " leftMargin=" &
Chr(34) & "0" & Chr(34) & " topMargin=" & Chr(34) & "0" & Chr(34) & "
rightMargin=" & Chr(34) & "0" & Chr(34) & " runat=" & Chr(34) & "server" &
Chr(34) & ">"))

' set META REFRESH as well in case script is disabled
' use long delay so that script can load page first if
possible
phRefresh.Contr ols.Clear()
phRefresh.Contr ols.Add(New LiteralControl( "<meta
http-equiv=" & Chr(34) & "refresh" & Chr(34) & " content=" & Chr(34) &
"30;url=" & sRefreshURL & Chr(34) & ">"))
Else

' not IE so use META REFRESH to start loading next page
' allow 3 seconds for progress bar image to load

phRefresh.Contr ols.Clear()
phRefresh.Contr ols.Add(New LiteralControl( "<meta
http-equiv=" & Chr(34) & "Refresh" & Chr(34) & " content=" & Chr(34) &
"3;url=" & sRefreshURL & Chr(34) & ">"))

End If

' hide Upload file controls and show "wait" section
Dim WaitCnt As Control =
LoadControl("../binFileUpload/ProgressCnt.asc x")
phUploader.Cont rols.Clear()
phResults.Contr ols.Clear()
phWait.Controls .Add(WaitCnt)

'pnlUploadFile. Visible = False
'pnlWait.Visibl e = True
Dim objUpload As UploadCnt
objUpload.Uploa dData()

Else

' get query string
Dim iUpload As String = Request.QuerySt ring("Upload")
If iUpload = "" Then

'pnlUploadFile. Visible = True
phWait.Controls .Clear()
phResults.Contr ols.Clear()
phUploader.Cont rols.Add(Upload Cnt)

Else
phUploader.Cont rols.Clear()
phWait.Controls .Clear()
Dim ResultsCnt As Control =
LoadControl("../binFileUpload/ResultsCnt.ascx ")
phResults.Contr ols.Add(Results Cnt)

End If
Dim sRefreshURL As String = Request.Url.ToS tring() &
"?Upload=Fa lse"
End If
End Sub

End Class
USER CONTROL...

Imports System.Data.Sql Client
Imports System.Data
Imports System.IO
Public Class UploadCnt
Inherits System.Web.UI.U serControl

#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
Protected WithEvents phHeader As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phHeaderMenu As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents ImageTitle As System.Web.UI.W ebControls.Text Box
Protected WithEvents Image4 As System.Web.UI.W ebControls.Imag e
Protected WithEvents fldDescription As System.Web.UI.W ebControls.Text Box
Protected WithEvents Image3 As System.Web.UI.W ebControls.Imag e
Protected WithEvents Image1 As System.Web.UI.W ebControls.Imag e
Protected WithEvents fldOwner As System.Web.UI.W ebControls.Text Box
Protected WithEvents ddlOffice As System.Web.UI.W ebControls.Drop DownList
Protected WithEvents Image5 As System.Web.UI.W ebControls.Imag e
Protected WithEvents lblMessage As System.Web.UI.W ebControls.Labe l
Protected WithEvents urlUploadedFile s As
System.Web.UI.W ebControls.Hype rLink
Protected WithEvents phQuickLinks As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phFooter As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents Table2 As System.Web.UI.H tmlControls.Htm lTable
Protected WithEvents ImageFile As System.Web.UI.H tmlControls.Htm lInputFile
Protected WithEvents Upload As System.Web.UI.W ebControls.Butt on

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

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

'Loads user controls
Dim c1 As Control = LoadControl("../userControls/footer.ascx")
phFooter.Contro ls.Add(c1)
Dim c2 As Control = LoadControl("../userControls/headerMenu.ascx ")
phHeaderMenu.Co ntrols.Add(c2)
Dim c3 As Control = LoadControl("../userControls/Header.ascx")
phHeader.Contro ls.Add(c3)
Dim c4 As Control = LoadControl("../userControls/QuickLinks.ascx ")
phQuickLinks.Co ntrols.Add(c4)

End Sub
Sub UploadData()
'Dim ImageFile As System.Web.UI.H tmlControls.Htm lInputFile
Dim imgstream As Stream = ImageFile.Poste dFile.InputStre am
Dim imgdata(ImageFi le.PostedFile.C ontentLength) As Byte
imgstream.Read( imgdata, 0, ImageFile.Poste dFile.ContentLe ngth)
Dim MyConn As New
SqlConnection(C onfigurationSet tings.AppSettin gs("strConn"))
Dim cmd As New SqlCommand("fil eUpload", MyConn)
cmd.CommandType = CommandType.Sto redProcedure

Dim titleparam As New SqlParameter("@ fileTitle", SqlDbType.NVarC har,
255)
Dim descriptionpara m As New SqlParameter("@ fileDescription ",
SqlDbType.NVarC har, 255)
Dim Ownerparam As New SqlParameter("@ fileOwner", SqlDbType.NVarC har,
255)
Dim Officeparam As New SqlParameter("@ officeID", SqlDbType.Int)
Dim typeparam As New SqlParameter("@ fileType", SqlDbType.NVarC har,
100)
Dim dataparam As New SqlParameter("@ fileData", SqlDbType.Image )

'Dim ImageTitle As System.Web.UI.W ebControls.Text Box
'Dim fldOwner As System.Web.UI.W ebControls.Text Box
'Dim fldDescription As System.Web.UI.W ebControls.Text Box
'Dim ddlOffice As System.Web.UI.W ebControls.Drop DownList

titleparam.Valu e = ImageTitle.Text
descriptionpara m.Value = fldDescription. Text
Ownerparam.Valu e = fldOwner.Text
Officeparam.Val ue = ddlOffice.Selec tedIndex
typeparam.Value = ImageFile.Poste dFile.ContentTy pe
dataparam.Value = imgdata

cmd.Parameters. Add(titleparam)
cmd.Parameters. Add(description param)
cmd.Parameters. Add(Ownerparam)
cmd.Parameters. Add(Officeparam )
cmd.Parameters. Add(typeparam)
cmd.Parameters. Add(dataparam)

MyConn.Open()
cmd.ExecuteNonQ uery()
MyConn.Close()
End Sub
End Class
Was this post helpful to you?

Why should I rate a post?

Expand AllCollapse All

Nov 19 '05 #1
3 2234
Tim:
NullReference exceptions are typically easy to track down. My guess is
simply that ImageFile isn't a control in your user control. In other words,
there's no:
<input type="file" id="ImageFile" runat="server" /> in yoru ascx
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Tim::.." <myatix_at_hotm ail.com> wrote in message
news:D3******** *************** ***********@mic rosoft.com...
Can someone please help....

I'm having major issues with a user control I'm tring to create!

I an trying to execute a sub called UploadData() from a user control which
I
managed to do but for some reason I keep getting the error:

Exception Details: System.NullRefe renceException: Object reference not set
to an instance of an object.

Source Error:
Line 114: Sub UploadData()
Line 115: 'Dim ImageFile As
System.Web.UI.H tmlControls.Htm lInputFile
Line 116: Dim imgstream As Stream =
ImageFile.Poste dFile.InputStre am
Line 117: Dim imgdata(ImageFi le.PostedFile.C ontentLength) As Byte
Line 118: imgstream.Read( imgdata, 0,
ImageFile.Poste dFile.ContentLe ngth)

Error is on line 116...

I know that the sub works because if I put it staight into the aspx page
it
works fine but as soon as I put the sub into the User Control it seems to
stop working as ImageFile.Poste dFile.InputStre am = nothing...

Can someone please please HELP.... Why does this happen???

Thanks

ASPX PAGE...

Imports System.Data.Sql Client
Imports System.Data
Imports System.IO

Public Class binUpload
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
Protected WithEvents Menu1 As skmMenu.Menu
Protected WithEvents phHeader As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phHeaderMenu As
System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phFooter As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phQuickLinks As
System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phRefresh As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phBody As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phUploader As
System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phWait As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phResults As System.Web.UI.W ebControls.Plac eHolder
'NOTE: The following placeholder declaration is required by the Web
Form
Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

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

phBody.Controls .Add(New LiteralControl( "<body bottomMargin=" &
Chr(34) & "0" & Chr(34) & "leftMargin =" & Chr(34) & "0" & Chr(34) &
"topMargin= " & Chr(34) & "0" & Chr(34) & "rightMargi n=" & Chr(34) & "0" &
Chr(34) & "runat=" & Chr(34) & "server" & Chr(34) & ">"))
Dim UploadCnt As Control =
LoadControl("../binFileUpload/UploadCnt.ascx" )
phWait.Controls .Clear()
phResults.Contr ols.Clear()
phUploader.Cont rols.Add(Upload Cnt)

If Page.IsPostBack Then

' user submitted file to be uploaded
' create URL with query string to confirm file upload
' next page will not be a postback, so viewstate will be lost
Dim sRefreshURL As String = Request.Url.ToS tring() &
"?Upload=Tr ue"

If Request.Browser .Browser = "IE" Then
phBody.Controls .Clear()
phBody.Controls .Add(New LiteralControl( "<body onload=" &
Chr(34) & "loadTarget (" & Chr(39) & sRefreshURL & Chr(39) & ")" & Chr(59)
&
Chr(34) & " bottomMargin=" & Chr(34) & "0" & Chr(34) & " leftMargin=" &
Chr(34) & "0" & Chr(34) & " topMargin=" & Chr(34) & "0" & Chr(34) & "
rightMargin=" & Chr(34) & "0" & Chr(34) & " runat=" & Chr(34) & "server" &
Chr(34) & ">"))

' set META REFRESH as well in case script is disabled
' use long delay so that script can load page first if
possible
phRefresh.Contr ols.Clear()
phRefresh.Contr ols.Add(New LiteralControl( "<meta
http-equiv=" & Chr(34) & "refresh" & Chr(34) & " content=" & Chr(34) &
"30;url=" & sRefreshURL & Chr(34) & ">"))
Else

' not IE so use META REFRESH to start loading next page
' allow 3 seconds for progress bar image to load

phRefresh.Contr ols.Clear()
phRefresh.Contr ols.Add(New LiteralControl( "<meta
http-equiv=" & Chr(34) & "Refresh" & Chr(34) & " content=" & Chr(34) &
"3;url=" & sRefreshURL & Chr(34) & ">"))

End If

' hide Upload file controls and show "wait" section
Dim WaitCnt As Control =
LoadControl("../binFileUpload/ProgressCnt.asc x")
phUploader.Cont rols.Clear()
phResults.Contr ols.Clear()
phWait.Controls .Add(WaitCnt)

'pnlUploadFile. Visible = False
'pnlWait.Visibl e = True
Dim objUpload As UploadCnt
objUpload.Uploa dData()

Else

' get query string
Dim iUpload As String = Request.QuerySt ring("Upload")
If iUpload = "" Then

'pnlUploadFile. Visible = True
phWait.Controls .Clear()
phResults.Contr ols.Clear()
phUploader.Cont rols.Add(Upload Cnt)

Else
phUploader.Cont rols.Clear()
phWait.Controls .Clear()
Dim ResultsCnt As Control =
LoadControl("../binFileUpload/ResultsCnt.ascx ")
phResults.Contr ols.Add(Results Cnt)

End If
Dim sRefreshURL As String = Request.Url.ToS tring() &
"?Upload=Fa lse"
End If
End Sub

End Class
USER CONTROL...

Imports System.Data.Sql Client
Imports System.Data
Imports System.IO
Public Class UploadCnt
Inherits System.Web.UI.U serControl

#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
Protected WithEvents phHeader As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phHeaderMenu As
System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents ImageTitle As System.Web.UI.W ebControls.Text Box
Protected WithEvents Image4 As System.Web.UI.W ebControls.Imag e
Protected WithEvents fldDescription As
System.Web.UI.W ebControls.Text Box
Protected WithEvents Image3 As System.Web.UI.W ebControls.Imag e
Protected WithEvents Image1 As System.Web.UI.W ebControls.Imag e
Protected WithEvents fldOwner As System.Web.UI.W ebControls.Text Box
Protected WithEvents ddlOffice As
System.Web.UI.W ebControls.Drop DownList
Protected WithEvents Image5 As System.Web.UI.W ebControls.Imag e
Protected WithEvents lblMessage As System.Web.UI.W ebControls.Labe l
Protected WithEvents urlUploadedFile s As
System.Web.UI.W ebControls.Hype rLink
Protected WithEvents phQuickLinks As
System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phFooter As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents Table2 As System.Web.UI.H tmlControls.Htm lTable
Protected WithEvents ImageFile As
System.Web.UI.H tmlControls.Htm lInputFile
Protected WithEvents Upload As System.Web.UI.W ebControls.Butt on

'NOTE: The following placeholder declaration is required by the Web
Form
Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

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

'Loads user controls
Dim c1 As Control = LoadControl("../userControls/footer.ascx")
phFooter.Contro ls.Add(c1)
Dim c2 As Control = LoadControl("../userControls/headerMenu.ascx ")
phHeaderMenu.Co ntrols.Add(c2)
Dim c3 As Control = LoadControl("../userControls/Header.ascx")
phHeader.Contro ls.Add(c3)
Dim c4 As Control = LoadControl("../userControls/QuickLinks.ascx ")
phQuickLinks.Co ntrols.Add(c4)

End Sub
Sub UploadData()
'Dim ImageFile As System.Web.UI.H tmlControls.Htm lInputFile
Dim imgstream As Stream = ImageFile.Poste dFile.InputStre am
Dim imgdata(ImageFi le.PostedFile.C ontentLength) As Byte
imgstream.Read( imgdata, 0, ImageFile.Poste dFile.ContentLe ngth)
Dim MyConn As New
SqlConnection(C onfigurationSet tings.AppSettin gs("strConn"))
Dim cmd As New SqlCommand("fil eUpload", MyConn)
cmd.CommandType = CommandType.Sto redProcedure

Dim titleparam As New SqlParameter("@ fileTitle",
SqlDbType.NVarC har,
255)
Dim descriptionpara m As New SqlParameter("@ fileDescription ",
SqlDbType.NVarC har, 255)
Dim Ownerparam As New SqlParameter("@ fileOwner",
SqlDbType.NVarC har,
255)
Dim Officeparam As New SqlParameter("@ officeID", SqlDbType.Int)
Dim typeparam As New SqlParameter("@ fileType", SqlDbType.NVarC har,
100)
Dim dataparam As New SqlParameter("@ fileData", SqlDbType.Image )

'Dim ImageTitle As System.Web.UI.W ebControls.Text Box
'Dim fldOwner As System.Web.UI.W ebControls.Text Box
'Dim fldDescription As System.Web.UI.W ebControls.Text Box
'Dim ddlOffice As System.Web.UI.W ebControls.Drop DownList

titleparam.Valu e = ImageTitle.Text
descriptionpara m.Value = fldDescription. Text
Ownerparam.Valu e = fldOwner.Text
Officeparam.Val ue = ddlOffice.Selec tedIndex
typeparam.Value = ImageFile.Poste dFile.ContentTy pe
dataparam.Value = imgdata

cmd.Parameters. Add(titleparam)
cmd.Parameters. Add(description param)
cmd.Parameters. Add(Ownerparam)
cmd.Parameters. Add(Officeparam )
cmd.Parameters. Add(typeparam)
cmd.Parameters. Add(dataparam)

MyConn.Open()
cmd.ExecuteNonQ uery()
MyConn.Close()
End Sub
End Class
Was this post helpful to you?

Why should I rate a post?

Expand AllCollapse All

Nov 19 '05 #2
Hi Karl,

Thanks for the reply... The thing is the control is in the ASCX file!

The other strange thing is if I take the code from the control and put it
straight into the page it works file!

Any other ideas.... I'm stuck....

"Karl Seguin" wrote:
Tim:
NullReference exceptions are typically easy to track down. My guess is
simply that ImageFile isn't a control in your user control. In other words,
there's no:
<input type="file" id="ImageFile" runat="server" /> in yoru ascx
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Tim::.." <myatix_at_hotm ail.com> wrote in message
news:D3******** *************** ***********@mic rosoft.com...
Can someone please help....

I'm having major issues with a user control I'm tring to create!

I an trying to execute a sub called UploadData() from a user control which
I
managed to do but for some reason I keep getting the error:

Exception Details: System.NullRefe renceException: Object reference not set
to an instance of an object.

Source Error:
Line 114: Sub UploadData()
Line 115: 'Dim ImageFile As
System.Web.UI.H tmlControls.Htm lInputFile
Line 116: Dim imgstream As Stream =
ImageFile.Poste dFile.InputStre am
Line 117: Dim imgdata(ImageFi le.PostedFile.C ontentLength) As Byte
Line 118: imgstream.Read( imgdata, 0,
ImageFile.Poste dFile.ContentLe ngth)

Error is on line 116...

I know that the sub works because if I put it staight into the aspx page
it
works fine but as soon as I put the sub into the User Control it seems to
stop working as ImageFile.Poste dFile.InputStre am = nothing...

Can someone please please HELP.... Why does this happen???

Thanks

ASPX PAGE...

Imports System.Data.Sql Client
Imports System.Data
Imports System.IO

Public Class binUpload
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
Protected WithEvents Menu1 As skmMenu.Menu
Protected WithEvents phHeader As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phHeaderMenu As
System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phFooter As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phQuickLinks As
System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phRefresh As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phBody As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phUploader As
System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phWait As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phResults As System.Web.UI.W ebControls.Plac eHolder
'NOTE: The following placeholder declaration is required by the Web
Form
Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

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

phBody.Controls .Add(New LiteralControl( "<body bottomMargin=" &
Chr(34) & "0" & Chr(34) & "leftMargin =" & Chr(34) & "0" & Chr(34) &
"topMargin= " & Chr(34) & "0" & Chr(34) & "rightMargi n=" & Chr(34) & "0" &
Chr(34) & "runat=" & Chr(34) & "server" & Chr(34) & ">"))
Dim UploadCnt As Control =
LoadControl("../binFileUpload/UploadCnt.ascx" )
phWait.Controls .Clear()
phResults.Contr ols.Clear()
phUploader.Cont rols.Add(Upload Cnt)

If Page.IsPostBack Then

' user submitted file to be uploaded
' create URL with query string to confirm file upload
' next page will not be a postback, so viewstate will be lost
Dim sRefreshURL As String = Request.Url.ToS tring() &
"?Upload=Tr ue"

If Request.Browser .Browser = "IE" Then
phBody.Controls .Clear()
phBody.Controls .Add(New LiteralControl( "<body onload=" &
Chr(34) & "loadTarget (" & Chr(39) & sRefreshURL & Chr(39) & ")" & Chr(59)
&
Chr(34) & " bottomMargin=" & Chr(34) & "0" & Chr(34) & " leftMargin=" &
Chr(34) & "0" & Chr(34) & " topMargin=" & Chr(34) & "0" & Chr(34) & "
rightMargin=" & Chr(34) & "0" & Chr(34) & " runat=" & Chr(34) & "server" &
Chr(34) & ">"))

' set META REFRESH as well in case script is disabled
' use long delay so that script can load page first if
possible
phRefresh.Contr ols.Clear()
phRefresh.Contr ols.Add(New LiteralControl( "<meta
http-equiv=" & Chr(34) & "refresh" & Chr(34) & " content=" & Chr(34) &
"30;url=" & sRefreshURL & Chr(34) & ">"))
Else

' not IE so use META REFRESH to start loading next page
' allow 3 seconds for progress bar image to load

phRefresh.Contr ols.Clear()
phRefresh.Contr ols.Add(New LiteralControl( "<meta
http-equiv=" & Chr(34) & "Refresh" & Chr(34) & " content=" & Chr(34) &
"3;url=" & sRefreshURL & Chr(34) & ">"))

End If

' hide Upload file controls and show "wait" section
Dim WaitCnt As Control =
LoadControl("../binFileUpload/ProgressCnt.asc x")
phUploader.Cont rols.Clear()
phResults.Contr ols.Clear()
phWait.Controls .Add(WaitCnt)

'pnlUploadFile. Visible = False
'pnlWait.Visibl e = True
Dim objUpload As UploadCnt
objUpload.Uploa dData()

Else

' get query string
Dim iUpload As String = Request.QuerySt ring("Upload")
If iUpload = "" Then

'pnlUploadFile. Visible = True
phWait.Controls .Clear()
phResults.Contr ols.Clear()
phUploader.Cont rols.Add(Upload Cnt)

Else
phUploader.Cont rols.Clear()
phWait.Controls .Clear()
Dim ResultsCnt As Control =
LoadControl("../binFileUpload/ResultsCnt.ascx ")
phResults.Contr ols.Add(Results Cnt)

End If
Dim sRefreshURL As String = Request.Url.ToS tring() &
"?Upload=Fa lse"
End If
End Sub

End Class
USER CONTROL...

Imports System.Data.Sql Client
Imports System.Data
Imports System.IO
Public Class UploadCnt
Inherits System.Web.UI.U serControl

#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
Protected WithEvents phHeader As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phHeaderMenu As
System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents ImageTitle As System.Web.UI.W ebControls.Text Box
Protected WithEvents Image4 As System.Web.UI.W ebControls.Imag e
Protected WithEvents fldDescription As
System.Web.UI.W ebControls.Text Box
Protected WithEvents Image3 As System.Web.UI.W ebControls.Imag e
Protected WithEvents Image1 As System.Web.UI.W ebControls.Imag e
Protected WithEvents fldOwner As System.Web.UI.W ebControls.Text Box
Protected WithEvents ddlOffice As
System.Web.UI.W ebControls.Drop DownList
Protected WithEvents Image5 As System.Web.UI.W ebControls.Imag e
Protected WithEvents lblMessage As System.Web.UI.W ebControls.Labe l
Protected WithEvents urlUploadedFile s As
System.Web.UI.W ebControls.Hype rLink
Protected WithEvents phQuickLinks As
System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents phFooter As System.Web.UI.W ebControls.Plac eHolder
Protected WithEvents Table2 As System.Web.UI.H tmlControls.Htm lTable
Protected WithEvents ImageFile As
System.Web.UI.H tmlControls.Htm lInputFile
Protected WithEvents Upload As System.Web.UI.W ebControls.Butt on

'NOTE: The following placeholder declaration is required by the Web
Form
Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

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

'Loads user controls
Dim c1 As Control = LoadControl("../userControls/footer.ascx")
phFooter.Contro ls.Add(c1)
Dim c2 As Control = LoadControl("../userControls/headerMenu.ascx ")
phHeaderMenu.Co ntrols.Add(c2)
Dim c3 As Control = LoadControl("../userControls/Header.ascx")
phHeader.Contro ls.Add(c3)
Dim c4 As Control = LoadControl("../userControls/QuickLinks.ascx ")
phQuickLinks.Co ntrols.Add(c4)

End Sub
Sub UploadData()
'Dim ImageFile As System.Web.UI.H tmlControls.Htm lInputFile
Dim imgstream As Stream = ImageFile.Poste dFile.InputStre am
Dim imgdata(ImageFi le.PostedFile.C ontentLength) As Byte
imgstream.Read( imgdata, 0, ImageFile.Poste dFile.ContentLe ngth)
Dim MyConn As New
SqlConnection(C onfigurationSet tings.AppSettin gs("strConn"))
Dim cmd As New SqlCommand("fil eUpload", MyConn)
cmd.CommandType = CommandType.Sto redProcedure

Dim titleparam As New SqlParameter("@ fileTitle",
SqlDbType.NVarC har,
255)
Dim descriptionpara m As New SqlParameter("@ fileDescription ",
SqlDbType.NVarC har, 255)
Dim Ownerparam As New SqlParameter("@ fileOwner",
SqlDbType.NVarC har,
255)
Dim Officeparam As New SqlParameter("@ officeID", SqlDbType.Int)
Dim typeparam As New SqlParameter("@ fileType", SqlDbType.NVarC har,
100)
Dim dataparam As New SqlParameter("@ fileData", SqlDbType.Image )

'Dim ImageTitle As System.Web.UI.W ebControls.Text Box
'Dim fldOwner As System.Web.UI.W ebControls.Text Box
'Dim fldDescription As System.Web.UI.W ebControls.Text Box
'Dim ddlOffice As System.Web.UI.W ebControls.Drop DownList

titleparam.Valu e = ImageTitle.Text
descriptionpara m.Value = fldDescription. Text
Ownerparam.Valu e = fldOwner.Text
Officeparam.Val ue = ddlOffice.Selec tedIndex
typeparam.Value = ImageFile.Poste dFile.ContentTy pe
dataparam.Value = imgdata

cmd.Parameters. Add(titleparam)
cmd.Parameters. Add(description param)
cmd.Parameters. Add(Ownerparam)
cmd.Parameters. Add(Officeparam )
cmd.Parameters. Add(typeparam)
cmd.Parameters. Add(dataparam)

Nov 19 '05 #3
Tim:
I'm going to have to stick to my first recommendation. You must be taking
more than the sub and also moving the ascx code? Why don't you just try to
debug and see if ImageFile is a nothing?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Tim::.." <myatix_at_hotm ail.com> wrote in message
news:E5******** *************** ***********@mic rosoft.com...
Hi Karl,

Thanks for the reply... The thing is the control is in the ASCX file!

The other strange thing is if I take the code from the control and put it
straight into the page it works file!

Any other ideas.... I'm stuck....

"Karl Seguin" wrote:
Tim:
NullReference exceptions are typically easy to track down. My guess is
simply that ImageFile isn't a control in your user control. In other
words,
there's no:
<input type="file" id="ImageFile" runat="server" /> in yoru ascx
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Tim::.." <myatix_at_hotm ail.com> wrote in message
news:D3******** *************** ***********@mic rosoft.com...
> Can someone please help....
>
> I'm having major issues with a user control I'm tring to create!
>
> I an trying to execute a sub called UploadData() from a user control
> which
> I
> managed to do but for some reason I keep getting the error:
>
> Exception Details: System.NullRefe renceException: Object reference not
> set
> to an instance of an object.
>
> Source Error:
>
>
> Line 114: Sub UploadData()
> Line 115: 'Dim ImageFile As
> System.Web.UI.H tmlControls.Htm lInputFile
> Line 116: Dim imgstream As Stream =
> ImageFile.Poste dFile.InputStre am
> Line 117: Dim imgdata(ImageFi le.PostedFile.C ontentLength) As
> Byte
> Line 118: imgstream.Read( imgdata, 0,
> ImageFile.Poste dFile.ContentLe ngth)
>
> Error is on line 116...
>
> I know that the sub works because if I put it staight into the aspx
> page
> it
> works fine but as soon as I put the sub into the User Control it seems
> to
> stop working as ImageFile.Poste dFile.InputStre am = nothing...
>
> Can someone please please HELP.... Why does this happen???
>
> Thanks
>
> ASPX PAGE...
>
> Imports System.Data.Sql Client
> Imports System.Data
> Imports System.IO
>
> Public Class binUpload
> 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
> Protected WithEvents Menu1 As skmMenu.Menu
> Protected WithEvents phHeader As
> System.Web.UI.W ebControls.Plac eHolder
> Protected WithEvents phHeaderMenu As
> System.Web.UI.W ebControls.Plac eHolder
> Protected WithEvents phFooter As
> System.Web.UI.W ebControls.Plac eHolder
> Protected WithEvents phQuickLinks As
> System.Web.UI.W ebControls.Plac eHolder
> Protected WithEvents phRefresh As
> System.Web.UI.W ebControls.Plac eHolder
> Protected WithEvents phBody As System.Web.UI.W ebControls.Plac eHolder
> Protected WithEvents phUploader As
> System.Web.UI.W ebControls.Plac eHolder
> Protected WithEvents phWait As System.Web.UI.W ebControls.Plac eHolder
> Protected WithEvents phResults As
> System.Web.UI.W ebControls.Plac eHolder
> 'NOTE: The following placeholder declaration is required by the Web
> Form
> Designer.
> 'Do not delete or move it.
> Private designerPlaceho lderDeclaration As System.Object
>
> 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
>
> phBody.Controls .Add(New LiteralControl( "<body bottomMargin=" &
> Chr(34) & "0" & Chr(34) & "leftMargin =" & Chr(34) & "0" & Chr(34) &
> "topMargin= " & Chr(34) & "0" & Chr(34) & "rightMargi n=" & Chr(34) & "0"
> &
> Chr(34) & "runat=" & Chr(34) & "server" & Chr(34) & ">"))
> Dim UploadCnt As Control =
> LoadControl("../binFileUpload/UploadCnt.ascx" )
> phWait.Controls .Clear()
> phResults.Contr ols.Clear()
> phUploader.Cont rols.Add(Upload Cnt)
>
> If Page.IsPostBack Then
>
> ' user submitted file to be uploaded
> ' create URL with query string to confirm file upload
> ' next page will not be a postback, so viewstate will be
> lost
> Dim sRefreshURL As String = Request.Url.ToS tring() &
> "?Upload=Tr ue"
>
> If Request.Browser .Browser = "IE" Then
> phBody.Controls .Clear()
> phBody.Controls .Add(New LiteralControl( "<body onload=" &
> Chr(34) & "loadTarget (" & Chr(39) & sRefreshURL & Chr(39) & ")" &
> Chr(59)
> &
> Chr(34) & " bottomMargin=" & Chr(34) & "0" & Chr(34) & " leftMargin=" &
> Chr(34) & "0" & Chr(34) & " topMargin=" & Chr(34) & "0" & Chr(34) & "
> rightMargin=" & Chr(34) & "0" & Chr(34) & " runat=" & Chr(34) &
> "server" &
> Chr(34) & ">"))
>
> ' set META REFRESH as well in case script is disabled
> ' use long delay so that script can load page first if
> possible
> phRefresh.Contr ols.Clear()
> phRefresh.Contr ols.Add(New LiteralControl( "<meta
> http-equiv=" & Chr(34) & "refresh" & Chr(34) & " content=" & Chr(34) &
> "30;url=" & sRefreshURL & Chr(34) & ">"))
> Else
>
> ' not IE so use META REFRESH to start loading next page
> ' allow 3 seconds for progress bar image to load
>
> phRefresh.Contr ols.Clear()
> phRefresh.Contr ols.Add(New LiteralControl( "<meta
> http-equiv=" & Chr(34) & "Refresh" & Chr(34) & " content=" & Chr(34) &
> "3;url=" & sRefreshURL & Chr(34) & ">"))
>
> End If
>
> ' hide Upload file controls and show "wait" section
> Dim WaitCnt As Control =
> LoadControl("../binFileUpload/ProgressCnt.asc x")
> phUploader.Cont rols.Clear()
> phResults.Contr ols.Clear()
> phWait.Controls .Add(WaitCnt)
>
> 'pnlUploadFile. Visible = False
> 'pnlWait.Visibl e = True
> Dim objUpload As UploadCnt
> objUpload.Uploa dData()
>
> Else
>
> ' get query string
> Dim iUpload As String = Request.QuerySt ring("Upload")
> If iUpload = "" Then
>
> 'pnlUploadFile. Visible = True
> phWait.Controls .Clear()
> phResults.Contr ols.Clear()
> phUploader.Cont rols.Add(Upload Cnt)
>
> Else
> phUploader.Cont rols.Clear()
> phWait.Controls .Clear()
> Dim ResultsCnt As Control =
> LoadControl("../binFileUpload/ResultsCnt.ascx ")
> phResults.Contr ols.Add(Results Cnt)
>
> End If
> Dim sRefreshURL As String = Request.Url.ToS tring() &
> "?Upload=Fa lse"
> End If
> End Sub
>
> End Class
>
>
> USER CONTROL...
>
> Imports System.Data.Sql Client
> Imports System.Data
> Imports System.IO
>
>
> Public Class UploadCnt
> Inherits System.Web.UI.U serControl
>
> #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
> Protected WithEvents phHeader As
> System.Web.UI.W ebControls.Plac eHolder
> Protected WithEvents phHeaderMenu As
> System.Web.UI.W ebControls.Plac eHolder
> Protected WithEvents ImageTitle As System.Web.UI.W ebControls.Text Box
> Protected WithEvents Image4 As System.Web.UI.W ebControls.Imag e
> Protected WithEvents fldDescription As
> System.Web.UI.W ebControls.Text Box
> Protected WithEvents Image3 As System.Web.UI.W ebControls.Imag e
> Protected WithEvents Image1 As System.Web.UI.W ebControls.Imag e
> Protected WithEvents fldOwner As System.Web.UI.W ebControls.Text Box
> Protected WithEvents ddlOffice As
> System.Web.UI.W ebControls.Drop DownList
> Protected WithEvents Image5 As System.Web.UI.W ebControls.Imag e
> Protected WithEvents lblMessage As System.Web.UI.W ebControls.Labe l
> Protected WithEvents urlUploadedFile s As
> System.Web.UI.W ebControls.Hype rLink
> Protected WithEvents phQuickLinks As
> System.Web.UI.W ebControls.Plac eHolder
> Protected WithEvents phFooter As
> System.Web.UI.W ebControls.Plac eHolder
> Protected WithEvents Table2 As System.Web.UI.H tmlControls.Htm lTable
> Protected WithEvents ImageFile As
> System.Web.UI.H tmlControls.Htm lInputFile
> Protected WithEvents Upload As System.Web.UI.W ebControls.Butt on
>
> 'NOTE: The following placeholder declaration is required by the Web
> Form
> Designer.
> 'Do not delete or move it.
> Private designerPlaceho lderDeclaration As System.Object
>
> 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
>
> 'Loads user controls
> Dim c1 As Control = LoadControl("../userControls/footer.ascx")
> phFooter.Contro ls.Add(c1)
> Dim c2 As Control =
> LoadControl("../userControls/headerMenu.ascx ")
> phHeaderMenu.Co ntrols.Add(c2)
> Dim c3 As Control = LoadControl("../userControls/Header.ascx")
> phHeader.Contro ls.Add(c3)
> Dim c4 As Control =
> LoadControl("../userControls/QuickLinks.ascx ")
> phQuickLinks.Co ntrols.Add(c4)
>
> End Sub
>
>
> Sub UploadData()
> 'Dim ImageFile As System.Web.UI.H tmlControls.Htm lInputFile
> Dim imgstream As Stream = ImageFile.Poste dFile.InputStre am
> Dim imgdata(ImageFi le.PostedFile.C ontentLength) As Byte
> imgstream.Read( imgdata, 0, ImageFile.Poste dFile.ContentLe ngth)
>
>
> Dim MyConn As New
> SqlConnection(C onfigurationSet tings.AppSettin gs("strConn"))
> Dim cmd As New SqlCommand("fil eUpload", MyConn)
> cmd.CommandType = CommandType.Sto redProcedure
>
> Dim titleparam As New SqlParameter("@ fileTitle",
> SqlDbType.NVarC har,
> 255)
> Dim descriptionpara m As New SqlParameter("@ fileDescription ",
> SqlDbType.NVarC har, 255)
> Dim Ownerparam As New SqlParameter("@ fileOwner",
> SqlDbType.NVarC har,
> 255)
> Dim Officeparam As New SqlParameter("@ officeID", SqlDbType.Int)
> Dim typeparam As New SqlParameter("@ fileType",
> SqlDbType.NVarC har,
> 100)
> Dim dataparam As New SqlParameter("@ fileData", SqlDbType.Image )
>
> 'Dim ImageTitle As System.Web.UI.W ebControls.Text Box
> 'Dim fldOwner As System.Web.UI.W ebControls.Text Box
> 'Dim fldDescription As System.Web.UI.W ebControls.Text Box
> 'Dim ddlOffice As System.Web.UI.W ebControls.Drop DownList
>
> titleparam.Valu e = ImageTitle.Text
> descriptionpara m.Value = fldDescription. Text
> Ownerparam.Valu e = fldOwner.Text
> Officeparam.Val ue = ddlOffice.Selec tedIndex
> typeparam.Value = ImageFile.Poste dFile.ContentTy pe
> dataparam.Value = imgdata
>
> cmd.Parameters. Add(titleparam)
> cmd.Parameters. Add(description param)
> cmd.Parameters. Add(Ownerparam)
> cmd.Parameters. Add(Officeparam )
> cmd.Parameters. Add(typeparam)
> cmd.Parameters. Add(dataparam)
>

Nov 19 '05 #4

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

Similar topics

3
2563
by: Tim Thomas | last post by:
Hi, I am very new to .NET and am in the process of building my first web application. I will briefly describe what i am trying to achieve: I have a system where suppliers register their details, their locations, and then add themselves to categories. Each category requires additional info from the suppliers, this additional category info is stored in its own DB table. a suppliers may add themselves to as many categories as required....
13
1584
by: Lloyd Sheen | last post by:
I have now spent 5 hours on google/msdn looking for something useful in the creation of user controls for asp.net. The VS 2003 has very limited support for things such as absolute positioning of the control etc.
6
11296
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header" Src="WebControls/Header.ascx" %> The web user control contains the following server controls
6
12285
by: grist2mill | last post by:
I want to create a standard tool bar that appears on all pages that is a control. The toolbar has a button 'New'. What I wolud like when the user clicks on 'New' depends on the page they are on. I would like to do this by defining a NewFunc() that is different in each (code-behind) page which is called by the standard 'New' button in the toolbar. How can I get this to work? So far I have the following (which doesnt work). When the user...
5
1649
by: Dave | last post by:
(Second Try) Greetings, I have an asp.net web application that utilizes a User Control at the top of the page. My User Control contains a Server Control menu which will require postbacks. I currently cannot get this to happen, but I know the functionality is
7
1941
by: Smithers | last post by:
I have a non trivial ASP.NET Web application that implements its navigation system via a user control (menu.ascx) placed on every page. It is important to note that the user control that hosts the menu is injected into every page at runtime when the page is requested (i.e., it's not declared in any ASPX). The user control contains a menu that is dynamically populated and styled at runtime (fwiw: it's ComponentArt's Menu for ASP.NET -...
4
1753
by: thomson | last post by:
Hi all, i do have a user control with 4 buttons, and all the events are firing properly, My problem is that i need to right an event handler in the user control, which gets fired after a specific process is done,, but the form which will host the user control has to specify what has to be done Something like this , if the event is fired it should call the event in
8
260
by: Paul Bromley | last post by:
I am trying to get somewhere with user controls and have come up against an obstacle with using relative paths. I have a dataset in my user control, and have tried to enter the path with the following:- dsResultsTable.ReadXml(Application.StartupPath & "\Textfiles\ResultsTable.xml") It does not like this, as it takes the application path to be C:\Program
8
3024
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the way I'm going about doing this might be a little off. I'd appreciate some help. Below is the code I have thus far but I'm not sure how to reference the user control within the foreach loop. <asp:Panel ID="pnlRosterProfile" runat="Server" />
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9116
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
8099
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
6702
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
6011
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
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3228
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
2637
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.