I downloaded Refinery.Barcodes.Reader.dll, and am using this:
Imports BusinessRefinery.Barcodes.Reader
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub btnread_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnread.Click
Dim barcodes As String() = BarCodeReader.scanBarCode("D://QRSAMPLE.png", BusinessRefinery.Barcodes.Reader.BarCodeType.QRCODE)
End Sub
End Class
It runs fine; no errors are thrown. But how do I see the result of the decoding process?
Try adding myTextBox.Text = barcodes before the End Sub.
edit:
After seeing comments, I think what you're running into is that scanBarCode returns an array, not a String. Check that, and try something like this:
Imports BusinessRefinery.Barcodes.Reader
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub btnread_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnread.Click
Dim barcodes As String() = BarCodeReader.scanBarCode("D://QRSAMPLE.png", BusinessRefinery.Barcodes.Reader.BarCodeType.QRCODE)
myTextbox.Text = barcodes(0)
End Sub
End Class
Related
After a PostBack caused by ddlPlant_SelectedIndexChanged, I need to set set HttpContext.Current.Session("PlantNumber"). This needs to happen after ddlPlant loads in Site.Master, but before the code in Default.aspx needs the value.
Public Class SiteMaster Inherits MasterPage
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init
If (Not Page.IsPostBack) Then
ddlPlant.DataSource = myDataSource
ddlPlant.DataBind()
ddlPlant.SelectedValue = "1"
End If
HttpContext.Current.Session("PlantNumber") = ddlPlant.SelectedValue
End Sub
Protected Sub ddlPlant_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ddlPlant.SelectedIndexChanged
End Sub
End Class
Public Class _Default Inherits Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim units As New List(Of EquipmentModel)
For Each unit As EquipmentModel In getUnits.Out.Results
If (CStr(unit.Plant_ID) = HttpContext.Current.Session("PlantNumber")) Then
units.Add(unit)
End If
Next
gvEquipmentUnit.DataSource = units.OrderBy(Function(n) n.Equipment_ID)
gvEquipmentUnit.DataBind()
End Sub
With the code above, when Session("PlantNumber") is set after PostBack, ddlPlant.SelectedIndex = Nothing, and ddlPlant.SelectedValue is an empty string.
I've tried moving the Session("PlantNumber") = ddlPlant.SelectedValue line to Site.Master's Page_Load instead, but that runs after it is needed in Default.aspx.vb
I looked up PreLoad, but apparently it doesn't work for the Master page.
Ultimately, I decided not to use a Session variable, and instead call the control directly from any page that needs that value on load (almost all of them):
DirectCast(Master.FindControl("ddlPlant"), DropDownList).SelectedValue
Hi I have website which has usercontrol, I can load the control. However if I assign the value of property of the user control, I get error" Type "WebUserControl) is not defined. Can someone told me how to solve it. Thanks in advance.
There is the code to use my Usercontrol
Partial Class Test
Inherits System.Web.UI.Page
Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
Dim ctrl As Control
ctrl = Page.LoadControl("Management/Profile/WebUserControl.ascx")
ctrl.ID = "ctrl_1"
CType(ctrl, WebUserControl).Level = 6 //this line cause error
PlaceHolder1.Controls.Add(ctrl)
End Sub
End Class
Here is my WebUserControl
Partial Class Management_Profile_WebUserControl
Inherits System.Web.UI.UserControl
Private m_Level As Integer
Public Property Level() As Integer
Get
Return m_Level
End Get
Set(ByVal Value As Integer)
m_Level = Value
End Set
End Property
Protected Sub Management_Profile_WebUserControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Text = m_Level
End Sub
End Class
We would like to change the following coding so it will use parameters to prevent injection attacks.
Here is the code in the Public Class area:
Public Class Parents1
Inherits System.Web.UI.Page
Dim theTableAdapter As New DataSetParentsSummaryTableAdapters.ParentsSummaryTableAdapter
Here is what we have in the page_load:
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
GridViewParentsSummary.DataSource = theTableAdapter.GetData("ALL")
End Sub
Here is the code used to load a GridView with data from a Search button click:
Protected Sub ButtonSearch_Click(sender As Object, e As EventArgs) Handles ButtonSearch.Click
GridViewParentsSummary.DataSource = theTableAdapter.GetData(TextBoxSearch.Text)
End Sub
Can you show the needed code required to use parameters?
I may seem dumb but this has had me going around in circles.
The report sits on the Report Server and requires ONE parameter "GROUPNAME". my code gives me a cast error when I try to set the parameters.
Please help:
Imports Microsoft.Reporting.webforms
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim ReportParameter(0)
ReportViewerMain.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote
ReportViewerMain.ServerReport.ReportServerUrl = New Uri("http://localhost/ReportServer")
ReportViewerMain.ServerReport.ReportPath = "/RptTest/RptTestParm"
ReportViewerMain.ShowParameterPrompts = True
ReportViewerMain.ShowPrintButton = True
Dim rptParameters As New ReportParameter(1)
rptParameters = New ReportParameter("GROUPNAME", "Adm01")
ReportViewerMain.ServerReport.SetParameters(rptParameters)
ReportViewerMain.ZoomPercent = 100
ReportViewerMain.ServerReport.Refresh()
End Sub
End Class
This is my code so far.
Thanks
Mac
your problem lies in your code itself
you have not properly instantiated the reportparameter array
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim ReportParameter(0)
ReportViewerMain.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote
ReportViewerMain.ServerReport.ReportServerUrl = New Uri("http://localhost/ReportServer")
ReportViewerMain.ServerReport.ReportPath = "/RptTest/RptTestParm"
ReportViewerMain.ShowParameterPrompts = True
ReportViewerMain.ShowPrintButton = True
Dim rptParameters As New ReportParameter(1)
RptParameters(0) = New ReportParameter("GROUPNAME", "Adm01")
ReportViewerMain.ServerReport.SetParameters(rptParameters)
ReportViewerMain.ZoomPercent = 100
ReportViewerMain.ServerReport.Refresh()
End Sub
you have not instantiated the array for the report parameters properly
thanks
I am trying to assign a theme based on browser type. I would like to do this in a base class so it would only need to be in one place (I am using a master page). I coded the following but the "OnLoad" here is performed before the "Page_PreInit". This needs to go in Page_PreInit, but why isn't it firing?
Imports Microsoft.VisualBasic
Public Class MyBaseClass
Inherits System.Web.UI.Page
Private Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs)
'Assign the CSS Theme based on the Browser Type
If (Request.Browser.Type = "IE8") Then
Page.Theme = "Standard-IE8"
Else
Page.Theme = "Standard"
End If
End Sub
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
End Sub
End Class
Then, I have my Login page coded to inherit the base class:
Partial Class Login
'Inherits System.Web.UI.Page
Inherits MyBaseClass
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Thank you,
James
You need to override OnPreInit in the base class.
Protected Overrides Sub OnPreInit(ByVal e As System.EventArgs)
'Assign the CSS Theme based on the Browser Type
If (Request.Browser.Type = "IE8") Then
Page.Theme = "Standard-IE8"
Else
Page.Theme = "Standard"
End If
MyBase.OnPreInit(e)
End Sub
See here for more information on using a custom base class.