Asp.net Vbscript Error - asp.net

Please tell me where I have gone wrong in this script. I am getting this error.
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: BC30002: Type 'ProcessStartInfo' is not defined.
Source Error:
Line 5: Public Shared Function ExecuteCommand(Command As String, Timeout As Integer) As Integer
Line 6: Dim ExitCode As Integer
*Line 7: Dim ProcessInfo As ProcessStartInfo*
Line 8: Dim Process As Process
Line 9:
Source File: C:\Inetpub\wwwroot\ServiceFileUploadRE.aspx Line: 7
The Script:
<%# Page Language=VBScript %>
<script runat="server">
Public Shared Function ExecuteCommand(Command As String, Timeout As Integer) As Integer
Dim ExitCode As Integer
Dim ProcessInfo As ProcessStartInfo
Dim Process As Process
ProcessInfo = New ProcessStartInfo("cmd.exe", "/C " + Command)
ProcessInfo.CreateNoWindow = True
ProcessInfo.UseShellExecute = False
Process = Process.Start(ProcessInfo)
Process.WaitForExit(Timeout)
ExitCode = Process.ExitCode
Process.Close()
Return ExitCode
End Function
Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
If FileUpload1.HasFile Then
Try
FileUpload1.SaveAs("C:\Inetpub\wwwroot\upload\" & _
FileUpload1.FileName)
Label1.Text = "File name: " & _
FileUpload1.PostedFile.FileName & "<br>" & _
"File Size: " & _
FileUpload1.PostedFile.ContentLength & " kb<br>" & _
"Content type: " & _
FileUpload1.PostedFile.ContentType
Catch ex As Exception
Label1.Text = "ERROR: " & ex.Message.ToString()
End Try
Else
Label1.Text = "You have not specified a file."
End If
End Sub
ExecuteCommand("REN C:\Document.rtf YES.rtf",100)
</script>
.......

Maybe place the line
<%# Import Namespace = "System.Diagnostics" %>
directly after <% Page....
If that does not work, then check whether you are using .NET Framework 4.

Related

Is it possible to read/write tags in kepserver using VB.NET application?

We are using following document for creating a VB.NET windows application to communicate with KepServerEx.
Title: ClientAce: Creating a Simple Windows Form Application
https://www.kepware.com/getattachment/66dac2e9-1496-4b22-9301-454e506a5ca6/clientace-simple-windows-form-application.pdf
Using the above document, we could successfully read data from KepServerEx.
However we also want to send the data inputted in VB.NET application back to the KepServerEx. Is this possible?
Solved by using following code -
"Kepware.ClientAce.OpcDaClient.DaServerMgt.Write(itemIdentifiers, OPCWriteValue)"
where -
itemIdentifiers(n)
Kepware.ClientAce.OpcDaClient.ItemIdentifier
contains tags definition
OPCWriteValue(n)
Kepware.ClientAce.OpcDaClient.ItemValue
contains tag values
Full code below:
Imports Kepware.ClientAce
Public Class Form1
Inherits System.Windows.Forms.Form
Dim maxAge As Integer = 0
Dim WithEvents daServerMgt As New Kepware.ClientAce.OpcDaClient.DaServerMgt
Dim activeClientSubscriptionHandle As Integer
Dim activeServerSubscriptionHandle As Integer
Dim itemIdentifiers(1) As Kepware.ClientAce.OpcDaClient.ItemIdentifier
Dim itemValues(1) As Kepware.ClientAce.OpcDaClient.ItemValue
Dim OPCWriteValue(1) As Kepware.ClientAce.OpcDaClient.ItemValue
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim url As String
url = "opcda://localhost/Kepware.KEPServerEX.V6"
Dim clientHandle As Integer
clientHandle = 1
Dim connectInfo As New Kepware.ClientAce.OpcDaClient.ConnectInfo
connectInfo.ClientName = "OPC UA Test Client"
connectInfo.LocalId = "en"
connectInfo.KeepAliveTime = 60000
connectInfo.RetryAfterConnectionError = True
connectInfo.RetryInitialConnection = False
Dim connectFailed As Boolean
connectFailed = False
itemIdentifiers(0) = New Kepware.ClientAce.OpcDaClient.ItemIdentifier
itemIdentifiers(0).ItemName = "Channel1.Device1.Tag1"
itemIdentifiers(0).ClientHandle = 0
itemIdentifiers(0).DataType = Type.GetType("System.Int16")
itemIdentifiers(1) = New Kepware.ClientAce.OpcDaClient.ItemIdentifier
itemIdentifiers(1).ItemName = "Channel1.Device1.Tag2"
itemIdentifiers(1).ClientHandle = 1
itemIdentifiers(1).DataType = Type.GetType("System.Int16")
Try
daServerMgt.Connect(url, clientHandle, connectInfo, connectFailed)
Catch ex As Exception
MsgBox("Handled Connect exception. Reason: " & ex.Message)
' Make sure following code knows connection failed:
connectFailed = True
End Try
Dim clientSubscriptionHandle As Integer = 1
Dim active As Boolean = True
Dim updateRate As Integer = 1000
Dim deadBand As Single = 0
Dim revisedUpdateRate As Integer
Try
daServerMgt.Subscribe(clientSubscriptionHandle, active, updateRate, revisedUpdateRate, deadBand, itemIdentifiers, activeServerSubscriptionHandle)
' Handle result:
' Save the active client subscription handle for use in
' DataChanged events:
activeClientSubscriptionHandle = clientSubscriptionHandle
' Check item result ID:
For itemIndex = 0 To 1
If itemIdentifiers(itemIndex).ResultID.Succeeded = False Then
' Show a message box if an item could not be added to subscription.
' You would probably use some other, less annoying, means to alert
' the user to failed item enrolments in an actual application.
MsgBox("Failed to add item " & itemIdentifiers(itemIndex).ItemName & " to subscription")
End If
Next
Catch ex As Exception
MsgBox("Handled Subscribe exception. Reason: " & ex.Message)
End Try
Try
daServerMgt.Read( _
maxAge, _
itemIdentifiers, _
itemValues)
' Handle results
Dim item As Integer
For item = 0 To 1
If itemIdentifiers(item).ResultID.Succeeded = True Then
Console.WriteLine( _
"Value: " & itemValues(item).Value & _
" Quality: " & itemValues(item).Quality.Name & _
" Timestamp: " & itemValues(item).TimeStamp)
Else
Console.WriteLine("Read failed for item: " & _
itemIdentifiers(item).ItemName)
End If
Next
Catch ex As Exception
Console.WriteLine("Read exception. Reason: " & ex.Message)
End Try
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
OPCWriteValue(0) = New Kepware.ClientAce.OpcDaClient.ItemValue
OPCWriteValue(0).Value = TextBox1.Text
OPCWriteValue(1) = New Kepware.ClientAce.OpcDaClient.ItemValue
OPCWriteValue(1).Value = TextBox2.Text
Try
daServerMgt.Write(itemIdentifiers, OPCWriteValue)
Catch ex As Exception
'Handle the write exception
Console.WriteLine("Sync write failed with exception " & ex.Message)
End Try
End Sub
End Class

vb.net if else logic flow error

I am debugging some code in an ASP.net web application project.
I have an If/Else statement nested in a Try/Catch block. Whenever an error occurs within the If block, rather than immediately jumping into the Catch block, it falls into the Else block.
I have stepped through the code repeatedly to witness this happening. When I throw an exception within the if block, I would expect logic to flow into the catch block, and I would never expect to see the if block get hit, and then the else block get hit, that seems to completely defeat the purpose of the if/else logic.
Here is the code in question:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
LoadDocument()
End Sub
Private Sub LoadDocument()
Dim taDocuments As New SecureTableAdapters.IndividualDocumentsTableAdapter
Dim dtDocuments As New Secure.IndividualDocumentsDataTable
Dim iDocumentID As Integer = CInt(Request.QueryString("iDocumentID"))
Dim sFileName As String
Dim isMac As Boolean = clsApplication.isMac(Request.Browser.Platform)
Dim bDownloaded As Boolean = False
Try
If taDocuments.FillBy_IndividualDocumentID(dtDocuments, iDocumentID) > 0 Then
Dim oRow As Secure.IndividualDocumentsRow = dtDocuments.Rows(0)
sFileName = "Statement-" & oRow.sFileNumber & ".pdf"
If oRow.sDocumentName.ToUpper.Contains("LEDES") Or oRow.sDocumentName.ToUpper.Contains("TEXT") Then
sFileName = sFileName.Replace("pdf", "txt")
End If
Dim b As Byte() = Nothing
If oRow.IsbExtractedNull = False AndAlso oRow.bExtracted Then
Dim sHost As String = "206.220.201.175"
Dim sPath As String = String.Format("/Legacy/{0}/{1}/{2}.pdf", oRow.iFirmID.ToString, "Individuals", oRow.iIndividualDocumentID.ToString)
b = DownloadDocument(sHost, sPath)
If b Is Nothing Then
'When this line is hit, logic jumps to the else block with the comment below
Throw New Exception("FTP Download Failed")
Else
bDownloaded = True
End If
Else
bDownloaded = False
End If
If bDownloaded = False Then
b = getImage(iDocumentID, "oPDF", "iIndividualDocumentID", "tblIndividualDocuments")
If b Is Nothing Then
Throw New Exception
End If
End If
If isMac Then
Response.ContentType = "application/x-macbinary"
Else
Response.ContentType = "application/octet-stream"
End If
Response.Expires = 0
Response.AddHeader("Content-Disposition", "attachment; filename=""" & sFileName & """")
Response.BinaryWrite(b)
Else
'--->When the exception occurs, logic jumps to this else block
Throw New Exception
End If
Catch ex As Exception
Response.Write("Sorry, that statement could not be located. Please try again, or call us at xxx.xxx.xxxx for further information.")
clsApplication.EmailError("An error occurred downloading a statement: " & vbCrLf & ex.Source & vbCrLf & ex.Message & vbCrLf & ex.StackTrace)
End Try
End Sub
How is this possible?
It sounds like you're using the debugger with Optimizations still turned on. This can cause the Step Traceing to act in seemingly illogical and even impossible ways. This is caused because after the optimizer moves the code and variables around and consolidates different statements, there is no longer a simple or straight-forward relationship between the lines of source-code and the executable instructions.
Sounds like the code you're debugging against might be out of sync with the code that's executing. Try rebuilding the whole solution.
I think you are probably mistaken:
Try the following in simple vb .net winforms program.
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Try
Dim doIt As Boolean = True
If doIt Then
Throw New Exception("throwing that stuff")
Else
MsgBox("in here - how did that happen?")
End If
Catch ex As Exception
MsgBox(String.Format("That makes sense. Exception is: {0}", ex))
End Try
End Sub
End Class

ASP.NET UserControl error - 'is not a member of 'System.Web.UI.UserControl'.'

I have to use an old user control written in the ASP.NET 2.0 days. the control is running fine in a ASP.NET 2.0 environment, but when the control is used with asp.net 4.0 it stops working.
Here is the code from the user control:
<%# Control Language="VB" Inherits="ControlDb" Src="../Bin/ControlDb.vb"%>
<%# import Namespace="System.Data" %>
<%# import Namespace="System" %>
<%# import Namespace="System.Data" %>
<%# import Namespace="System.Web" %>
<%# import Namespace="System.Web.UI" %>
<%# import Namespace="System.Web.UI.WebControls" %>
<%# import Namespace="System.Web.UI.HtmlControls" %>
<%# import Namespace="System.Data.OleDb" %>
<%# import Namespace="System.Configuration" %>
<script runat="server">
' Public isEditable as Boolean
Public Class CommonDb
Inherits System.Web.UI.Page
Dim ConnectionString As String = "<ConnectionString>"
Public Property dbConnection() As String
Get
Return ConnectionString
End Get
Set(ByVal Value As String)
ConnectionString = Value
End Set
End Property
Public Function Execute_GetID(ByVal strSQL As String) As Long
Dim dbConn As New OleDbConnection(ConnectionString)
Dim dbComm1 As New OleDbCommand(strSQL, dbConn)
Dim dbComm2 As New OleDbCommand("SELECT ##IDENTITY", dbConn)
dbConn.Open()
dbComm1.ExecuteNonQuery()
Dim id As Long = CLng(dbComm2.ExecuteScalar())
Return id
End Function
Function Execute(ByVal strSQL As String) As Integer
Dim dbConn As New OleDbConnection(ConnectionString)
Dim dbComm As New OleDbCommand(strSQL, dbConn)
Dim rowsAffected As Integer = 0
dbComm.Connection = dbConn
dbConn.Open()
Try
rowsAffected = dbComm.ExecuteNonQuery
Finally
dbConn.Close()
End Try
Return rowsAffected
End Function
Public Function FillData(ByVal strSQL As String) As DataSet
Dim conn As New OleDbConnection(ConnectionString)
Dim adapter As New OleDbDataAdapter
Dim ds As New DataSet
adapter.SelectCommand = New OleDbCommand(strSQL, conn)
adapter.Fill(ds)
Return ds
End Function
End Class
Private Cdb as new ControlDb()
Private dtR as DataTable
Private resourceIds as DataRow()
Sub Page_Load(Src As Object, E As EventArgs)
End Sub
Public Sub setData()
dtR = Cdb.FillData("SELECT resourceid FROM VEJLEDNING_RESOURCE WHERE centerid = '" & CenterId & "' AND date='" & DateTime & "' ORDER BY resourceid;").tables(0)
if dtR.rows.count > 0 then
Dim dtB as DataTable = Cdb.FillData("SELECT Count(resourceid) FROM VEJLEDNING_BOOKING WHERE resourceid='" & dtR.rows(0)("resourceid") & "'").tables(0)
RBtn.text = FormatDateTime(DateTime,vbShorttime) & "(" & dtR.rows.count & "/" & dtB.rows(0)(0) & ")"
RemBtn.Visible=true
CType(Page.FindControl("IntervalList"),DropDownList).Enabled=false
If dtB.rows(0)(0) >= dtR.rows.count
RBtnClass = "BookingBusyEdit"
else
RBtnClass = "BookingFree"
end if
else
RBtn.text = FormatDateTime(DateTime,vbShorttime) & "(0/0)"
RBtnClass = "BookingNormalEdit"
RemBtn.Visible=false
end if
End Sub
Public ReadOnly Property AddBtnId As Button
Get
Return AddBtn
End Get
End Property
Public ReadOnly Property RBtnId As Button
Get
Return RBtn
End Get
End Property
Public ReadOnly Property RemBtnId As Button
Get
Return RemBtn
End Get
End Property
Public Property Text As String
Get
Return RBtn.text
End Get
Set
RBtn.text = Value
End Set
End Property
Public Property DateTime As String
Get
Return ViewState("time")
End Get
Set
ViewState("time") = Value
End Set
End Property
Public Property CenterId As String
Get
Return ViewState("centerid")
End Get
Set
ViewState("centerid") = Value
End Set
End Property
Public Property isEditable As Boolean
Get
Return ViewState("isEditable")
End Get
Set
ViewState("isEditable") = Value
End Set
End Property
Public Property addBtnClass As String
Get
Return AddBtn.CssClass
End Get
Set
AddBtn.CssClass = Value
End Set
End Property
Public Property RBtnClass As String
Get
Return RBtn.CssClass
End Get
Set
RBtn.CssClass = Value
End Set
End Property
Public Property RemBtnClass As String
Get
Return RemBtn.CssClass
End Get
Set
RemBtn.CssClass = Value
End Set
End Property
Sub AddBtn_Click(sender As Object, e As EventArgs)
NyPost(ViewState("time"))
setData()
End Sub
Sub RBtn_Click(sender As Object, e As EventArgs)
Dim interval as Integer = CType(Page.FindControl("IntervalList"),DropDownList).SelectedItem.Value
if isEditable then
response.redirect("Resource.aspx?id=" & CenterId & "&dtm=" & DateTime & "&interval=" & interval)
else
response.redirect("Booking.aspx?id=" & CenterId & "&dtm=" & DateTime)
end if
End Sub
Sub RemBtn_Click(sender As Object, e As EventArgs)
setData()
Try
Cdb.Execute("DELETE FROM VEJLEDNING_RESOURCE WHERE centerid = '" & CenterId & "' AND date='" & DateTime & "'") ' Ryd
'Cdb.Execute("DELETE FROM VEJLEDNING_RESOURCE WHERE resourceid = '" & dtR.rows (dtR.rows.count-1)("resourceid") & "'") ' Fjern sidste
Catch ex As Exception
End Try
setData()
End Sub
Sub NyPost(dato)
Dim strSQL as string
Dim wn As Integer = DatePart("ww", dato, vbMonday, FirstWeekOfYear.FirstFourDays)
Dim interval as Integer = CType(Page.FindControl("IntervalList"),DropDownList).SelectedItem.Value
If not session("initialer") = nothing then
if wn = 53 then wn = 1
Try
strSQL = "INSERT INTO VEJLEDNING_RESOURCE ("
strSQL = strSQL & "centerid, "
strSQL = strSQL & "week, "
strSQL = strSQL & "interval, "
strSQL = strSQL & "initialer, "
strSQL = strSQL & "date "
strSQL = strSQL & ") "
strSQL = strSQL & "VALUES ("
strSQL = strSQL & "'" & CenterId & "', "
strSQL = strSQL & "'" & wn & "', "
strSQL = strSQL & "'" & interval & "', "
strSQL = strSQL & "'" & session("initialer") & "', "
strSQL = strSQL & "'" & dato & "' "
strSQL = strSQL & ")"
Cdb.Execute(strSQL)
Catch ex As Exception
End Try
End If
End sub
</script>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<asp:Button title="Tilføj ressource" id="AddBtn" onclick="AddBtn_Click" CssClass="BookingFree" Visible="true" Width="14px" runat="server" Text="+"></asp:Button>
</td>
<td width="100">
<asp:Button id="RBtn" onclick="RBtn_Click" Width="100px" runat="server"></asp:Button>
</td>
<td>
<asp:Button title="Slet ressource" id="RemBtn" onclick="RemBtn_Click" CssClass="BookingFree" Visible="true" Width="14px" runat="server" Text="-"></asp:Button>
</td>
</tr>
</table>
Here is the code from the file that uses the user control:
<%# Page Language="vb" Inherits="CommonDb" Src="../bin/CommonDb.vb" %>
<%# Import Namespace="System.Data" %>
<%# Import Namespace="System.Drawing" %>
<%# Register TagPrefix="MyControls" TagName="RB" Src="ResourceButton.ascx" %>
<script runat="server">
Dim Cdb As New CommonDb
Dim ResourceDst As DataTable
Dim BookingDst As DataTable
Dim dtmCurrent As Date = Now()
Dim intDatebuff = (Weekday(dtmCurrent, vbMonday) - 1) * -1
Dim dtmMonday As Date = FormatDateTime(DateAdd("d", intDatebuff, dtmCurrent), vbShortDate)
Dim WeekDays As String() = {"Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag"}
Dim dtmStart As String = "08:00"
Dim dtmEnd As String = "19:00"
Dim dtmInterval As Integer = 20
Dim BInterval As String() = {"10", "15", "20", "25", "30", "40", "60"}
Dim CenterId As String
Dim cssBtnBar As String
Dim isEditable As Boolean
Dim strOverskrift As String
Dim testYear As String
Sub Page_Load(ByVal Src As Object, ByVal E As EventArgs)
Response.Expires = 0
Response.AppendHeader("Refresh", Convert.ToString((Session.Timeout * 60) + 10) & ";URL=.")
CenterId = Request.QueryString("id")
If CenterId <> "" Or Not Session("initialer") Is Nothing Then
isEditable = (CenterId <> "" And Request.QueryString("admin") <> "" And Not Session("initialer") Is Nothing)
If Not isEditable Then
strOverskrift = "Book en tid : "
cssBtnBar = "display:none;"
Else
strOverskrift = "Læg vejledertider ind (" & Session("initialer") & ")"
End If
If Not IsPostBack Then
VisChatBtn(getChat())
Cdb.Execute("LP_Cleanup_Vejledning_resource") ' 52 uger
If Request.QueryString("dtm") <> "" Then dtmMonday = Request.QueryString("dtm")
ShowPage(dtmMonday)
ViewState("dtmMonday") = dtmMonday
Else
dtmMonday = ViewState("dtmMonday")
End If
Else
Response.Redirect(".")
End If
End Sub
Sub AddControl(ByVal day As String, ByVal e As RepeaterItemEventArgs)
'Dim uc = CType(e.Item.FindControl(day), Web.UI.UserControl)
Dim uc As Web.UI.UserControl = e.Item.FindControl(day)
Dim strTider As String = e.Item.DataItem(day).ToString
Dim ResourceRows As DataRow() = ResourceDst.Select("date='" & strTider & "'")
Dim rc As Integer = ResourceRows.Length
Dim BookingRows As DataRow() = BookingDst.Select("date='" & strTider & "'")
Dim br As Integer = BookingRows.Length
If isEditable Then
uc.RBtnId.text = FormatDateTime(e.Item.DataItem(day).ToString, vbShortTime) & "(" & rc & "/" & br & ")"
If rc = 0 Then
uc.RemBtnId.Visible = False
uc.RBtnClass = "BookingNormalEdit"
ElseIf br >= rc Then
uc.RBtnClass = "BookingBusyEdit"
Else
uc.RBtnClass = "BookingFree"
End If
Else
uc.RBtnId.text = FormatDateTime(e.Item.DataItem(day).ToString, vbShortTime)
uc.RemBtnId.Visible = False
uc.AddBtnId.Visible = False
If rc = 0 Then
setNormalBooking(uc, FormatDateTime(e.Item.DataItem(day).ToString, vbShortTime))
ElseIf br >= rc Then
uc.RBtnId.Attributes.add("onClick", "this.blur();return false;")
uc.RBtnClass = "BookingBusy"
Else
uc.RBtnClass = "BookingFree"
End If
End If
uc.isEditable = isEditable
uc.DateTime = strTider
uc.CenterId = CenterId
End Sub
Here is the error message:
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: BC30456: 'RBtnId' is not a member of 'System.Web.UI.UserControl'.
Source Error:
Line 209:
Line 210: If isEditable Then
Line 211: uc.RBtnId.text = FormatDateTime(e.Item.DataItem(day).ToString, vbShortTime) & "(" & rc & "/" & br & ")"
Line 212: If rc = 0 Then
Line 213: uc.RemBtnId.Visible = False
Source File: \\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx Line: 211
Show Detailed Compiler Output:
Microsoft (R) Visual Basic Compiler version 10.0.30319.233
Copyright (c) Microsoft Corporation. All rights reserved.
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(211) : error BC30456: 'RBtnId' is not a member of 'System.Web.UI.UserControl'.
uc.RBtnId.text = FormatDateTime(e.Item.DataItem(day).ToString, vbShortTime) & "(" & rc & "/" & br & ")"
~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(213) : error BC30456: 'RemBtnId' is not a member of 'System.Web.UI.UserControl'.
uc.RemBtnId.Visible = False
~~~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(214) : error BC30456: 'RBtnClass' is not a member of 'System.Web.UI.UserControl'.
uc.RBtnClass = "BookingNormalEdit"
~~~~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(216) : error BC30456: 'RBtnClass' is not a member of 'System.Web.UI.UserControl'.
uc.RBtnClass = "BookingBusyEdit"
~~~~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(218) : error BC30456: 'RBtnClass' is not a member of 'System.Web.UI.UserControl'.
uc.RBtnClass = "BookingFree"
~~~~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(221) : error BC30456: 'RBtnId' is not a member of 'System.Web.UI.UserControl'.
uc.RBtnId.text = FormatDateTime(e.Item.DataItem(day).ToString, vbShortTime)
~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(222) : error BC30456: 'RemBtnId' is not a member of 'System.Web.UI.UserControl'.
uc.RemBtnId.Visible = False
~~~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(223) : error BC30456: 'AddBtnId' is not a member of 'System.Web.UI.UserControl'.
uc.AddBtnId.Visible = False
~~~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(227) : error BC30456: 'RBtnId' is not a member of 'System.Web.UI.UserControl'.
uc.RBtnId.Attributes.add("onClick", "this.blur();return false;")
~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(228) : error BC30456: 'RBtnClass' is not a member of 'System.Web.UI.UserControl'.
uc.RBtnClass = "BookingBusy"
~~~~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(230) : error BC30456: 'RBtnClass' is not a member of 'System.Web.UI.UserControl'.
uc.RBtnClass = "BookingFree"
~~~~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(234) : error BC30456: 'isEditable' is not a member of 'System.Web.UI.UserControl'.
uc.isEditable = isEditable
~~~~~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(235) : error BC30456: 'DateTime' is not a member of 'System.Web.UI.UserControl'.
uc.DateTime = strTider
~~~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(236) : error BC30456: 'CenterId' is not a member of 'System.Web.UI.UserControl'.
uc.CenterId = CenterId
~~~~~~~~~~~
\\Webfilefs\websites\DATAPOOL006\u12jbyv\wwwroot\vejlederbooking\hfvuc.aspx(405) : warning BC40004: WithEvents variable 'header' conflicts with property 'header' in the base class 'Page' and should be declared 'Shadows'.
Protected WithEvents header As Global.System.Web.UI.WebControls.Literal
How do i use this control under 4.0?
I had some old UserControls that worked fine in Debug mode, but when I tried to publish the site, I received the same error you received, that a property I had defined for the control was "not a member of System.Web.UI.WebControl."
I thought that declaring the property as "Public" in the block at the top of my UserControl was sufficient. However, there seems to be something with way the aspnet_compiler works that caused it to fail to recognize this Property when I attempted to publish the site. I haven't done any digging into this to find out why it didn't work (deadlines, you know). If anyone could explain that behavior, I'd love to hear the reason behind it!
The fix? I ended up moving all of the code for the user control into a code behind file rather than including it in the tags at the top of the control itself. Once I did that, the site compiled and published without any errors.
I think WithEvents variable 'header' conflicts with property 'header' in the base class 'Page' and should be declared 'Shadows'. is creating problem. Try to resolve this error and see what happens.

How to clear the file after uploading?

I am using visual developer 2012 and have a simple form to upload the file to the server and then enter the name of the file into another table. For whatever reason it runs twice and enter the values twice in the second table:
Protected Sub BtnUploadImg_Click(sender As Object, e As EventArgs) Handles BtnUploadImg.Click
If IsPostBack Then
' Dim CurrentPath As String = Server.MapPath("C:\DSimages\")
If FileUpLoad1.HasFile = True Then
Try
FileUpLoad1.SaveAs("C:\DSimages\" & _
FileUpLoad1.FileName)
Label1.Text = "File name: " & _
FileUpLoad1.PostedFile.FileName & "<br>" & _
"File Size: " & _
FileUpLoad1.PostedFile.ContentLength & " kb<br>" & _
"Content type: " & _
FileUpLoad1.PostedFile.ContentType
ImageDataSource.InsertParameters("ImgName").DefaultValue = FileUpLoad1.PostedFile.FileName
Catch ex As Exception
Label1.Text = "ERROR: " & ex.Message.ToString()
End Try
Else
Label1.Text = "You have not specified a file."
End If
End If
ImageDataSource.Insert()
FileUpLoad1.PostedFile.InputStream.Dispose()
End Sub
Do you have the same code under the page load event? The postback will fire both events, so if you do it will run twice.

VB.NET Custom Errors Messages

I like to user custom errors in my site.
The Idea is to trap errors and display friendly meaningful messages to users.
The real error details (line number, Page ...) will sent to me by e-mail.
I am programming in VB.NET.
Until now every code that i found about this say's that i must use the global.asax for it.
I do not like to use global.asax, I just like to make an error page that will sent me a -email with all the error details.
Until now, i go to the web.config file and insert this line:
<customErrors defaultRedirect="test.aspx" mode="On"></customErrors>
test.aspx looks like this:
Sub Page_Error(sender as Object, e as EventArgs)
Dim ctxOBJ As HttpContext
Dim exceptionOBJ As Exception
Dim errorInfoTXT As String
ctxOBJ = HttpContext.Current()
exceptionOBJ = ctxOBJ.Server.GetLastError()
errorInfoTXT = "Offending URL: " & ctxOBJ.Request.Url.ToString() & _
"Source: " & exceptionOBJ.Source.ToString() & _
"Message: " & exceptionOBJ.Message.ToString() & _
"Stack trace: " & exceptionOBJ.StackTrace.ToString() & _
"Target Site: " & exceptionOBJ.TargetSite.ToString()
ctxOBJ.Response.Write (errorInfoTXT)
ctxOBJ.Server.ClearError ()
End Sub
When here is an error in some page its redirect me to test.aspx but not showing any error.
Thanks,
Roy Shoa.
You just need to change this to
Sub Page_Load(sender as Object, e as EventArgs)
It's not the error page that's erroring, so its error event never fires.

Resources