Click here to Skip to main content
15,891,529 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Option Strict On disallows late binding Pin
jkirkerx25-Jan-12 13:00
professionaljkirkerx25-Jan-12 13:00 
Question'Sys' is Undefined Error Pin
vishnukamath23-Jan-12 22:53
vishnukamath23-Jan-12 22:53 
AnswerRe: 'Sys' is Undefined Error Pin
Bryian Tan24-Jan-12 16:57
professionalBryian Tan24-Jan-12 16:57 
AnswerRe: 'Sys' is Undefined Error Pin
jkirkerx25-Jan-12 12:54
professionaljkirkerx25-Jan-12 12:54 
QuestionIE issue with canceling the onBeforeUnload function Pin
ccrook23-Jan-12 7:36
ccrook23-Jan-12 7:36 
QuestionIssue with AppleMAC-Safari Pin
vanikanc23-Jan-12 7:03
vanikanc23-Jan-12 7:03 
AnswerRe: Issue with AppleMAC-Safari Pin
jkirkerx23-Jan-12 12:24
professionaljkirkerx23-Jan-12 12:24 
QuestionModify webpage controls in a contentplaceholder from a class.vb file Pin
Member 840806423-Jan-12 5:01
Member 840806423-Jan-12 5:01 
I'm using VB.NET and ASP.NET in VS2005 to create a web application that has some very similar code in five different webpages. This code enables/disables various controls depending on the actions allowed in the current page. I would like to consolidate this code into a subroutine in a class.vb file and call it from the aspx.vb files.

I’m using a Master Page with four contentpageholders. Only one has the controls in question, but herein lies my problem. I can access the controls on webpages not using the Master Page, but can’t make the code work with the contentpageholder.

Here is the code in the class file:

Public Sub SetControls(ByVal Controltype As String, ByVal StartCtrl As Integer, ByVal StopCtrl As Integer, ByVal SetValue As Boolean)

Dim myPage As Page
Dim intIndex As Integer
Dim objPlaceHolder As ContentPlaceHolder

myPage = TryCast(HttpContext.Current.Handler, Page)

objPlaceHolder = TryCast(myPage.FindControl ("rightcolumn"), ContentPlaceHolder)

**** If Not objPlaceHolder Is Nothing Then **** “Nothing”
Select Case Controltype
Case "TextBox"
Dim txtTextBox As TextBox

For intIndex = StartCtrl To StopCtrl
txtTextBox = TryCast (myPage.FindControl("TextBox" & intIndex), TextBox)

If Not txtTextBox Is Nothing Then
txtTextBox.ReadOnly = SetValue
Else
Exit For
End If
Next
End Select

End If

End Sub

End Class



And I call the procedure like this:

Sub LockControls()

Dim objMiscUtilities As New MiscUtilities

objMiscUtilities.SetControls("TextBox", 2, 20, False)

End Sub



Whenever I test the program the “objPlaceHolder” is always nothing, so the rest of the code is bypassed.

Any help will be greatly appreciated.
Ron Brewer
AnswerRe: Modify webpage controls in a contentplaceholder from a class.vb file Pin
manognya kota23-Jan-12 6:49
manognya kota23-Jan-12 6:49 
GeneralRe: Modify webpage controls in a contentplaceholder from a class.vb file Pin
Member 840806423-Jan-12 11:17
Member 840806423-Jan-12 11:17 
GeneralRe: Modify webpage controls in a contentplaceholder from a class.vb file Pin
manognya kota23-Jan-12 19:23
manognya kota23-Jan-12 19:23 
NewsRe: Modify webpage controls in a contentplaceholder from a class.vb file Pin
Member 840806424-Jan-12 10:44
Member 840806424-Jan-12 10:44 
GeneralRe: Modify webpage controls in a contentplaceholder from a class.vb file Pin
manognya kota24-Jan-12 22:49
manognya kota24-Jan-12 22:49 
QuestionMaking multiple teams coexist Pin
_Zorro_23-Jan-12 4:21
professional_Zorro_23-Jan-12 4:21 
QuestionHTTPS implmentation issue in asp.net Pin
afsal qureshi23-Jan-12 3:47
afsal qureshi23-Jan-12 3:47 
AnswerRe: HTTPS implmentation issue in asp.net Pin
jkirkerx25-Jan-12 13:14
professionaljkirkerx25-Jan-12 13:14 
QuestionAsp.net rdlc reports hanging in production (Ajax application) Pin
nikam.chetan23-Jan-12 1:56
nikam.chetan23-Jan-12 1:56 
AnswerRe: Asp.net rdlc reports hanging in production (Ajax application) Pin
thatraja23-Jan-12 2:27
professionalthatraja23-Jan-12 2:27 
QuestionHow to build business layer in MVC3 project? Pin
Tesic Goran22-Jan-12 9:08
professionalTesic Goran22-Jan-12 9:08 
AnswerRe: How to build business layer in MVC3 project? Pin
Anurag Gandhi23-Jan-12 0:39
professionalAnurag Gandhi23-Jan-12 0:39 
QuestionSeveral HTTPS sites on the same server! possible? Pin
abbd22-Jan-12 7:59
abbd22-Jan-12 7:59 
QuestionIFrame name Pin
Ali Al Omairi(Abu AlHassan)22-Jan-12 2:20
professionalAli Al Omairi(Abu AlHassan)22-Jan-12 2:20 
AnswerRe: IFrame name Pin
Not Active22-Jan-12 4:00
mentorNot Active22-Jan-12 4:00 
GeneralRe: IFrame name Pin
Ali Al Omairi(Abu AlHassan)22-Jan-12 4:49
professionalAli Al Omairi(Abu AlHassan)22-Jan-12 4:49 
AnswerRe: IFrame name Pin
Ali Al Omairi(Abu AlHassan)24-Jan-12 20:34
professionalAli Al Omairi(Abu AlHassan)24-Jan-12 20:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.