hide datepicker using its type - asp.net

I am using the below code to Hide TextBox , Label and Dropdownlist. But how would i hide a datepicker ? can i do the same for datepicker in the below code ?
If (TypeOf ctrTexbox Is TextBox) Then
If isMasked Then
CType(ctrLabel, Label).Visible = True
CType(ctrTexbox, TextBox).Visible = False
Else
CType(ctrLabel, Label).Visible = False
CType(ctrTexbox, TextBox).Visible = True
End If
ElseIf (TypeOf ctrTexbox Is DropDownList) Then
If isMasked Then
CType(ctrLabel, Label).Visible = True
CType(ctrTexbox, DropDownList).Visible = False
Else
CType(ctrLabel, Label).Visible = False
CType(ctrTexbox, DropDownList).Visible = True
End If
html for datepicker
<BDP:BasicDatePicker Style="z-index: 205; left: 312px" ID="dtp" runat="server" width="250px" SelectedDate="1989-01-01" DateFormat="dd/MMM/yyyy">
<TextBoxStyle CssClass="inputbox" Width="250px" /></BDP:BasicDatePicker>

Sure you can, as BasicDatePicker is also derived from the same WebControl class :
ElseIf (TypeOf ctrTexbox Is BasicFrame.WebControls.BasicDatePicker) Then
If isMasked Then
CType(ctrLabel, Label).Visible = True
CType(ctrTexbox, BasicFrame.WebControls.BasicDatePicker).Visible = False
Else
CType(ctrLabel, Label).Visible = False
CType(ctrTexbox, BasicFrame.WebControls.BasicDatePicker).Visible = True
End If

Related

Gridview does not refresh display updated record

I am currently working on a project. I suddenly stumbled on a problem that really blew my brains. I have a function that displays the content of a table in a database to a gridview which I named bindGrid. It is working perfectly fine when I query 50 to 90 records. However when I query 100 records or more the gridview does not display the records until I change the value of my dropdown box that is set to autopostback.
Here is the sample of the code:
Protected Sub btnFilter_Click(sender As Object, e As EventArgs) Handles btnFilter.Click
If cboFilter.Text = "DMZ" Then
lblErrFilter.Visible = False
lblError.Visible = False
If drpYear.Text = "--Select--" Or drpMonth.Text = "--Select--" Or txtDMZ.Text = "--Select--" Or txtTop.Text = "" Then
If drpYear.Text = "--Select--" Then
lblErrYear.Visible = True
Else
lblErrYear.Visible = False
End If
If drpMonth.Text = "--Select--" Then
lblErrMonth.Visible = True
Else
lblErrMonth.Visible = False
End If
If txtDMZ.Text = "--Select--" Then
lblErrDMZ.Visible = True
Else
lblErrDMZ.Visible = False
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
Else
lblErrYear.Visible = False
lblErrMonth.Visible = False
lblErrDMZ.Visible = False
Call bindData()
'If Me.IsPostBack = True Then
Call bindGrid()
'End If
'
End If
'__________________________________________________________________________
'Zone filter
ElseIf cboFilter.Text = "Zone and Book" Then
lblErrFilter.Visible = False
lblError.Visible = False
If drpYear.Text = "--Select--" Or drpMonth.Text = "--Select--" Or txtZone.Text = "--Select--" Or txtTop.Text = "" Then
If drpYear.Text = "--Select--" Then
lblErrYear.Visible = True
Else
lblErrYear.Visible = False
End If
If drpMonth.Text = "--Select--" Then
lblErrMonth.Visible = True
Else
lblErrMonth.Visible = False
End If
If txtZone.Text = "--Select--" Then
lblErrZone.Visible = True
Else
lblErrZone.Visible = False
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
Else
lblErrYear.Visible = False
lblErrMonth.Visible = False
lblErrZone.Visible = False
Call bindData()
Call bindGrid()
End If
ElseIf cboFilter.Text = "Account Number" Then
If txtFrom.Visible = True And txtTo.Visible = True Then
If drpYear.Text = "--Select--" Or drpMonth.Text = "--Select--" Or txtFrom.Text = "" Or txtTo.Text = "" Then
If drpYear.Text = "--Select--" Then
lblErrYear.Visible = True
Else
lblErrYear.Visible = False
End If
If drpMonth.Text = "--Select--" Then
lblErrMonth.Visible = True
Else
lblErrMonth.Visible = False
End If
If txtFrom.Text = "" Then
lblErrR1.Visible = True
Else
lblErrR1.Visible = False
End If
If txtTo.Text = "" Then
lblErrR2.Visible = True
Else
lblErrR2.Visible = False
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
Else
Call bindData()
Call bindGrid()
End If
Else
If drpYear.Text = "--Select--" Or drpMonth.Text = "--Select--" Or lstAcct.Items.Count = 0 Then
If drpYear.Text = "--Select--" Then
lblErrYear.Visible = True
Else
lblErrYear.Visible = False
End If
If drpMonth.Text = "--Select--" Then
lblErrMonth.Visible = True
Else
lblErrMonth.Visible = False
End If
If lstAcct.Items.Count = 0 Then
lblErrAcct.Visible = True
Else
lblErrAcct.Visible = False
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
Else
lblErrYear.Visible = False
lblErrMonth.Visible = False
lblErrR1.Visible = False
lblErrR2.Visible = False
Call bindData()
Call bindGrid()
End If
End If
Else
If cboFilter.Text = "--Select--" Then
lblErrFilter.Visible = True
End If
lblError.Visible = True
lblError.Text = "No value specified for the following parameter(s) *."
End If
'Response.Redirect("~/Sites/CD/TopCon.aspx", True)
End Sub
as you can see the execution is done after I click on the filter button.
Here is my page load:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If User.Identity.IsAuthenticated = False Then
Response.Redirect("/Default.aspx", True)
Else
If User.IsInRole("chicken") = True Or User.IsInRole("dog") = True Or User.IsInRole("cat") = True Then
If Not IsPostBack Then
maxTop = 10
txtTop.Text = maxTop
Call bindData()
Call bindGrid()
lblUser.Text = lblUser.Text & User.Identity.Name
lblIP.Text = lblIP.Text & GetIPAddress()
cboFilter.TabIndex = 0
Call fillYear()
Call fillDMZCombo()
Call fillZoneCombo()
Call fillType()
Else
*Call bindGrid()*
End If
Else
Response.Redirect("/Default.aspx", True)
End If
End If
End Sub
Well I know the reason why the gridview refreshes when I click on my control that is set to autopostback it's because of the bindGrid that I inserted on my page_load inside the else.
It really seems to be a passive line of code. What really bothers me is why is it that my bindGrid inside the filter button does not execute when I query 100 records or more.
Here is my code for bindGrid:
Public Sub bindGrid()
IpAdd = GetIPAddress()
xUser = User.Identity.Name
ShowCon = New SqlConnection("some data connection")
ShowCon.Open()
cmdShowCon = ShowCon.CreateCommand
cmdShowCon.CommandTimeout = 600
cmdShowCon.CommandText = "some simple select statement"
daShowCon.SelectCommand = cmdShowCon
dsShowCon.Clear()
daShowCon.Fill(dsShowCon, "someTable")
grdTopCon.DataSource = dsShowCon
grdTopCon.DataBind()
End Sub
Any help would be much appreciated.
Try setting a breakpoint in the btnFilter_Click to see what's causing the problem. It maybe either caused by the algorithm inside it or inside the Page_Load event.

Trying to make a group of fields required on combobox selection in Access 2010

In Access 2010.
I have 3 separate groups of fields that can be active based on a combobox selection but I'm trying to get them to be required as well. I've looked everywhere but it doesn't appear to be any VB code to make a field required. Is there anyway I can accomplish this?
The code I have right now to make the selected group of fields active and make the one's not selected blank:
Private Sub Combo109_Click()
If Combo109 = "Germ" Then
cg_moisture.Enabled = True
cg_oil_nir.Enabled = True
extraneous_material.Enabled = True
fines.Enabled = True
cg_moisture.Enabled = True
cg_oil_nir.Enabled = True
extraneous_material.Enabled = True
fines.Enabled = True
Moist_cgm_nir.Enabled = False
prot_cgm_nir.Enabled = False
oil_cgm_nir.Enabled = False
meal_color.Enabled = False
load_out_temp.Enabled = False
moist_cgf_nir.Enabled = False
prot_cgf_nir.Enabled = False
oil_cgf_nir.Enabled = False
profat_nir.Enabled = False
starch_nir.Enabled = False
total_sug_nir.Enabled = False
loadout_temp.Enabled = False
screen_thrus.Enabled = False
screen_thrus.Value = ""
Moist_cgm_nir.Value = ""
prot_cgm_nir.Value = ""
oil_cgm_nir.Value = ""
meal_color.Value = ""
load_out_temp.Value = ""
moist_cgf_nir.Value = ""
prot_cgf_nir.Value = ""
oil_cgf_nir.Value = ""
profat_nir.Value = ""
starch_nir.Value = ""
total_sug_nir.Value = ""
loadout_temp.Value = ""
screen_thrus.Value = ""
screen_thrus.Value = ""
End If
IF all of the controls are in the 'Detail' section of your form, AND if a contrtol is Enabled, you require a value, then the code below should work. If you want more meaningful names to be displayed, either change your control names, or place a better name in the control 'Tag' field and reference that. The following code only checks Textboxes and CheckBoxes - modify to suit your needs.
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim ctl As Control
Dim blnMissing As Boolean
Dim strMissing As String
For Each ctl In Me.Section("Detail").Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acCheckBox Then
If ctl.Enabled = True Then
'Debug.Print ctl.Name & vbTab & ctl.Value
If ctl.Properties("Enabled") = True Then
If Me(ctl.Name) = "" Or IsNull(Me(ctl.Name)) Then
blnMissing = True
strMissing = strMissing & ctl.Name & "; "
End If
End If
End If
End If
Next ctl
If blnMissing = True Then
MsgBox "You are required to enter data in fields: " & strMissing, vbOKOnly + vbCritical, "Missing Required Data"
Cancel = True
End If
End Sub

Get filenotfoundexception using RadAsyncUpload

i use the Telerik radasyncupload control like this:
Web.Config
<appSettings>
<add key="Telerik.AsyncUpload.TemporaryFolder" value="~/App_Data/RadUploadTemp" />
</appSettings>
ASP.NET
<telerik:RadAsyncUpload ID="rauIconUpload" runat="server" ChunkSize="0" Localization-Cancel="Löschen" Localization-Remove="Entfernen" Localization-Select="Auswählen"
Culture="de-DE" Skin="MetroTouch" TargetFolder="img/icons" MaxFileInputsCount="1">
</telerik:RadAsyncUpload>
<telerik:RadButton ID="rbtnIconUpload" runat="server" Text="Speichern" Skin="MetroTouch"></telerik:RadButton>
VB.NET
Private Sub rbtnIconUpload_Click(sender As Object, e As EventArgs) Handles rbtnIconUpload.Click
If rtxtIconBezeichnung.Text = String.Empty Or rtxtIconBezeichnung.Text = Nothing Or CHKValidation(rtxtIconBezeichnung.Text) = False Then
rnfUngueltigeEingabe.Visible = True
Else
Try
For Each f As UploadedFile In rauIconUpload.UploadedFiles
Dim img As New System.Drawing.Bitmap(f.InputStream)
Dim h As Integer = img.Height
Dim w As Integer = img.Width
img.Dispose()
Dim fileName As String = f.GetName()
IconPfad = "~/img/icons/" & fileName
If w = 16 And h = 16 Then
IconSize = "16x16"
ElseIf w = 32 And h = 32 Then
IconSize = "32x32"
Else
rnfIconNichtErzeugt.Visible = True
Exit For
End If
IconErzeugt = Datenzugriff.CRTNeuesIcon(rtxtIconBezeichnung.Text, IconPfad, rcbIconGruppe.SelectedValue, IconSize)
If IconErzeugt = True Then
rnfIconErzeugt.Visible = True
Page.ClientScript.RegisterClientScriptBlock([GetType](), "CloseScript", "redirectParentPage('IconVerwaltung.aspx')", True)
Else
rnfIconNichtErzeugt.Visible = True
End If
Next
Catch ex As Exception
rnfIconNichtErzeugt.Visible = True
End Try
End If
End Sub
If i try to use InputStream i get a filenotfoundexeption. I added a Screanshot of this error.
So, does someone have a idea what i'm doing wrong?
Thank you for reading.
Daniel
Try to remove the TargetFolder property from the markup:
<telerik:RadAsyncUpload ID="rauIconUpload" runat="server" ChunkSize="0" Localization-Cancel="Löschen" Localization-Remove="Entfernen" Localization-Select="Auswählen"
Culture="de-DE" Skin="MetroTouch" MaxFileInputsCount="1">
</telerik:RadAsyncUpload>
and save the file manually from in the click button event.

Global Code segment in MVC View giving an error.... "Expression Expected."

I have a View in which I have a code block where I am setting some variables and later on using those variables to show or hide some areas...
When I build this website. A compilation error comes up on the line #( stating Syntax Error and another one stating Expression Expected. Can anyone guide me what I am doing wrong here....
#ModelType arwedes.WebShop.Model.Gruppe1Liste
#Code
End Code
#(
Dim lblInfoTitleText As String = String.Empty
Dim lblInfoText As String = String.Empty
Dim panelInfoVisibility As Boolean = False
Select Case WebSession.Menu
Case arwedes.WebShop.Web.Navigation.MenuEnum.Home
lblInfoTitleText = arwedes.WebShop.Model.Text.GetText("Info.HomeTitle", AppSession.Language)
lblInfoText = arwedes.WebShop.Model.Text.GetText("Info.Home", AppSession.Language)
panelInfoVisibility = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Reservieren
lblInfoTitleText = arwedes.WebShop.Model.Text.GetText("Info.ReservierenTitle", AppSession.Language)
lblInfoText = arwedes.WebShop.Model.Text.GetText("Info.Reservieren", AppSession.Language)
panelInfoVisibility = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Kaufen
lblInfoTitleText = arwedes.WebShop.Model.Text.GetText("Info.KaufenTitle", AppSession.Language)
lblInfoText = arwedes.WebShop.Model.Text.GetText("Info.Kaufen", AppSession.Language)
panelInfoVisibility = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Verkaufen
lblInfoTitleText = arwedes.WebShop.Model.Text.GetText("Info.VerkaufenTitle", AppSession.Language)
lblInfoText = arwedes.WebShop.Model.Text.GetText("Info.Verkaufen", AppSession.Language)
panelInfoVisibility = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Member
If Request.RawUrl.Contains("login") Then
lblInfoTitleText = arwedes.WebShop.Model.Text.GetText("Info.MemberTitle", AppSession.Language)
lblInfoText = arwedes.WebShop.Model.Text.GetText("Info.Member", AppSession.Language)
panelInfoVisibility = True
End If
End Select
Dim bShowCatMenu As Boolean = False
Select Case WebSession.Menu
Case arwedes.WebShop.Web.Navigation.MenuEnum.Home
bShowCatMenu = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Kaufen
bShowCatMenu = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Reservieren
bShowCatMenu = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Member
If Request.ServerVariables("SCRIPT_NAME") = "/membermenu.aspx" Or Request.ServerVariables("SCRIPT_NAME") = "/welcome.aspx" Then
bShowCatMenu = True
End If
End Select
)
#If panelInfoVisibility Then
#: <div id="panelInfo">
#: <p style="text-align: center; font-size: 8pt"> <b> <span id="lblInfoTitle">#lblInfoTitleText</span>
#: </b><br /> <span id="lblInfo">#lblInfoText</span> </p> </div>
End If
instead of #( ...) put your code inside the #Code ... End Code block.
Try like this:
#ModelType arwedes.WebShop.Model.Gruppe1Liste
#Code
Dim lblInfoTitleText As String = String.Empty
Dim lblInfoText As String = String.Empty
Dim panelInfoVisibility As Boolean = False
Select Case WebSession.Menu
Case arwedes.WebShop.Web.Navigation.MenuEnum.Home
lblInfoTitleText = arwedes.WebShop.Model.Text.GetText("Info.HomeTitle", AppSession.Language)
lblInfoText = arwedes.WebShop.Model.Text.GetText("Info.Home", AppSession.Language)
panelInfoVisibility = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Reservieren
lblInfoTitleText = arwedes.WebShop.Model.Text.GetText("Info.ReservierenTitle", AppSession.Language)
lblInfoText = arwedes.WebShop.Model.Text.GetText("Info.Reservieren", AppSession.Language)
panelInfoVisibility = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Kaufen
lblInfoTitleText = arwedes.WebShop.Model.Text.GetText("Info.KaufenTitle", AppSession.Language)
lblInfoText = arwedes.WebShop.Model.Text.GetText("Info.Kaufen", AppSession.Language)
panelInfoVisibility = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Verkaufen
lblInfoTitleText = arwedes.WebShop.Model.Text.GetText("Info.VerkaufenTitle", AppSession.Language)
lblInfoText = arwedes.WebShop.Model.Text.GetText("Info.Verkaufen", AppSession.Language)
panelInfoVisibility = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Member
If Request.RawUrl.Contains("login") Then
lblInfoTitleText = arwedes.WebShop.Model.Text.GetText("Info.MemberTitle", AppSession.Language)
lblInfoText = arwedes.WebShop.Model.Text.GetText("Info.Member", AppSession.Language)
panelInfoVisibility = True
End If
End Select
Dim bShowCatMenu As Boolean = False
Select Case WebSession.Menu
Case arwedes.WebShop.Web.Navigation.MenuEnum.Home
bShowCatMenu = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Kaufen
bShowCatMenu = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Reservieren
bShowCatMenu = True
Case arwedes.WebShop.Web.Navigation.MenuEnum.Member
If Request.ServerVariables("SCRIPT_NAME") = "/membermenu.aspx" Or Request.ServerVariables("SCRIPT_NAME") = "/welcome.aspx" Then
bShowCatMenu = True
End If
End Select
End Code
#If panelInfoVisibility Then
#: <div id="panelInfo">
#: <p style="text-align: center; font-size: 8pt"> <b> <span id="lblInfoTitle">#lblInfoTitleText</span>
#: </b><br /> <span id="lblInfo">#lblInfoText</span> </p> </div>
End If
This being said, code like the one you wrote doesn't belong to a view. So the real solution to your problem would be to externalize it (helper, view model?).
Can you ever imagine giving your views to a web designer? He will scream out in despair.

Lua recursive scrolling menu not working?

Hey guys, just wondering why ain't my menu working, I've been coding it for like 8 hours now and just can't figure out what's wrong.
Menu = {
label = "Mahin Menu",
current = current or true,
open = open or true,
subMenus = {}
}
function Menu.newSubMenu()
return {
setup = Menu.setup,
print = Menu.print,
toggleOpen = Menu.toggleOpen,
getCurrentMenu = Menu.getCurrentMenu,
getLastMenu = Menu.getLastMenu,
getNextMenu = Menu.getNextMenu,
getPrevMenu = Menu.getPrevMenu
}
end
function Menu:setup(m_parent, m_label, m_action)
self.parent = m_parent
self.label = m_label
self.action = m_action
self.subMenus = {}
self.current = false
self.open = false
table.insert(m_parent.subMenus, self)
end
function Menu:print(indent)
io.write(string.rep(" ", indent))
if #self.subMenus>0 then
if self.open == true then
io.write("[-]")
else
io.write("[+]")
end
else
io.write(" ")
end
if self.current == true then
io.write("<" .. self.label .. ">")
else
io.write(" " .. self.label)
end
io.write("\n")
if #self.subMenus>0 and self.open == true then
for i=1,#self.subMenus do
self.subMenus[i]:print(indent+1)
end
end
end
function Menu:toggleOpen()
if self.open == true then
self.open = false
else
self.open = true
end
end
function Menu:getCurrentMenu()
if self.current == true then
return self
else
for k=1,#self.subMenus do
local v = self.subMenus[k]:getCurrentMenu()
if v ~= nil then
return v
end
end
end
end
function Menu:getLastMenu()
if self.open == true and #self.subMenus > 0 then
return self.subMenus[#self.subMenus]:getLastMenu()
else
return self
end
end
function Menu:getNextMenu(bool)
bool = bool or false
if bool == false then
if #self.subMenus > 0 and self.open == true then
return self.subMenus[1]
end
end
if self.parent then
if self.parent.subMenus[#self.parent.subMenus] == self then
self.parent:getNextMenu(true)
else
for i=1,#self.parent.subMenus do
if self.parent.subMenus[i] == self then
print(self.parent.subMenus[i+1].label)
return self.parent.subMenus[i+1]
end
end
end
else
return self
end
end
function Menu:getPrevMenu()
if self.parent then
for k=1,#self.parent.subMenus do
if self.parent.subMenus[k] == self then
if k == 1 then
return self.parent
elseif #self.parent.subMenus[k-1].subMenus > 0 and self.parent.subMenus[k-1].open == true then
local x = self.parent.subMenus[k-1]
while #x.subMenus > 0 and x.open == true do
x = x.subMenus[#x.subMenus]
end
return x
else
return self.parent.subMenus[k-1]
end
end
end
else
return self
end
end
Test = Menu.newSubMenu()
Test:setup(Menu, "Test item")
Mahi = Menu.newSubMenu()
Mahi:setup(Menu, "Mahi item")
Mahi.open = true
Testx = Menu.newSubMenu()
Testx:setup(Mahi, "Lalall")
Testx.open= true
Sadmad = Menu.newSubMenu()
Sadmad:setup(Testx, "Woot")
Asd = Menu.newSubMenu()
Asd:setup(Menu, "Asd menu")
Asd.current = true
Menu.current = false
repeat
print(string.rep("\n",2))
Menu:print(0)
x=io.read()
if x == "z" then
x = Menu:getCurrentMenu()
print(Menu:getCurrentMenu().label)
print(Menu:getCurrentMenu():getNextMenu().label)
y = Menu:getCurrentMenu():getNextMenu()
x.current = false
y.current = true
elseif x == "a" then
x = Menu:getCurrentMenu()
y = Menu:getCurrentMenu():getPrevMenu()
x.current = false
y.current = true
end
until x == "sad"
"
there's the code, and when ever i try to move my current from "Asd menu" downwards, it'll error:
menu.lua:150: attempt to index a nil value
which doesn't make any sense, it's clearly declared, and I've tried adding prints and they always give me Asd menu O.o
Same goes for if I'll try to move from Woot to Asd menu, same exact error, and I have no idea why, since I added those prints
print(Menu:getCurrentMenu().label)
print(Menu:getCurrentMenu():getNextMenu().label)
and they do give me Asd menu, but then it says that trying to index a nil value at the second print line, but it sill does print? I'm out of ideas, any help out here?
You are missing a return statement in line 92.
Note that this line does not actually return anything, so the function is returning nil.
After changing it to return self.parent:getNextMenu(true) it seems to be working.

Resources