Click here to Skip to main content
15,912,400 members
Home / Discussions / Web Development
   

Web Development

 
QuestionPrinting a page from JavaScript Pin
happyheartcs9-Dec-06 23:28
happyheartcs9-Dec-06 23:28 
AnswerRe: Printing a page from JavaScript Pin
Bradml9-Dec-06 23:34
Bradml9-Dec-06 23:34 
GeneralRe: Printing a page from JavaScript Pin
happyheartcs10-Dec-06 0:44
happyheartcs10-Dec-06 0:44 
GeneralRe: Printing a page from JavaScript Pin
Bradml11-Dec-06 0:09
Bradml11-Dec-06 0:09 
QuestionWeb Service blocked??? Pin
Kschuler8-Dec-06 9:08
Kschuler8-Dec-06 9:08 
AnswerRe: Web Service blocked??? Pin
Pete O'Hanlon11-Dec-06 1:05
mvePete O'Hanlon11-Dec-06 1:05 
GeneralRe: Web Service blocked??? Pin
Kschuler15-Dec-06 4:50
Kschuler15-Dec-06 4:50 
QuestionDesigner property window doesn't show my component's style settings. Pin
howardjr8-Dec-06 8:36
howardjr8-Dec-06 8:36 
I've built a custom web/server-side component ComboBox. However, when I tried to explicitly
handle property assignments to the Style I get a message saying that that property may only
be set at runtime.

In my component I actually have three webcontrols: a image-button, a listbox, and a textbox,
which in my code, I use as storage for the various properties that my component supports,
including the Style properties for each of these controls using distinctive properties for
each one: ImageStyle, ListBoxStyle, and TextBoxStyle. And this works for them. Then, as I
said at the top of this message, I wanted to create an explicit property for the base
class's Style property, and got the error, so I created a new one called ComponentStyle,
and changed the Style in my component's tag from Style to ComponentStyle, but nothing shows
in the ComponentStyle property in the Designer's Property Window. Strangely, the inline
style values are getting rendered in the web-page, so they are being loaded, just not
showing in the designer.

Here is the code I'm using for my Style and ComponentStyle properties:

' --------------- Property Style --------------------------------
' Setting Browsable to False to hide this property from the Designer Property window.
' This property uses Shadow to allow me declare the Browsable directive.

<browsable(false), category("component"),="" defaultvalue(""),="" _
="" description("component="" level="" inline="" css="" string")=""> _
Public Shadows ReadOnly Property [Style]() As System.Web.UI.CssStyleCollection
Get
Return MyBase.Style
End Get
End Property ' Style

' ----------- Property ComponentStyle --------------------------
' This is the public version of the above property.
'
' The Getter uses the CssStyleCollectionAsString
' function to build a string containing the
' MyBase Style settings.
' ' The Setter uses the
' ApplyCssStyleStringToCssStyleCollection function
' to set the MyBase Style setting from a string.
'
' I know that these helper functions work, I use
' them on through out my program on the other
' components, including CssStyleCollectionAsString
' in the designer to render the component's styles
' for the editor.
'

<browsable(true), category("component"),="" defaultvalue(""),="" _
="" description("component="" level="" inline="" css="" string")=""> _
Public Property [ComponentStyle]() As String
Get
Return CssStyleCollectionAsString(MyBase.Style)
End Get
Set(ByVal Value As String)
ApplyCssStyleStringToCssStyleCollection(Value, MyBase.Style)
End Set
End Property ' ComponentStyle

'
' CssStyleCollectionAsString
'
' Convert a CssStyleCollection to a CSS Style Inline String.
'
' This method is also used by the designer,
' so it must be public.
'

Public Function CssStyleCollectionAsString( _
ByRef SrcCssStyleCollection As System.Web.UI.CssStyleCollection) As String
Dim SrcCssStyleCollectionCounter As Integer = SrcCssStyleCollection.Count
Dim KeyName As String
Dim KeyValue As String
Dim DestCssStyleString As String

If SrcCssStyleCollectionCounter > 0 Then
Dim Keys(SrcCssStyleCollectionCounter - 1) As String

'
' Copy the keys to a new array.
' Can't iterate on the Keys collection directly
' when the values are being changed. The code
' that makes all style names lower case isn't
' shown here, to reduce the code in this listing.
'
SrcCssStyleCollectionCounter = 0
For Each KeyName In SrcCssStyleCollection.Keys
If KeyName <> "" Then
Keys(SrcCssStyleCollectionCounter) = KeyName
SrcCssStyleCollectionCounter += 1
End If
Next

For Each KeyName In Keys
KeyValue = SrcCssStyleCollection( KeyName )
If Not KeyValue Is Nothing Then
DestCssStyleString &= KeyName & ": " & KeyValue
SrcCssStyleCollectionCounter -= 1
If SrcCssStyleCollectionCounter > 0 Then
DestCssStyleString &= "; "
End If
End If
Next
End If
Return DestCssStyleString
End Function ' End of CssStyleCollectionAsString

'
' ApplyCssStyleCollectionToCssStyleCollection
'
' Apply the CSS Style settings in one CssStyleCollection to another.
'

Public Sub ApplyCssStyleCollectionToCssStyleCollection( _
ByRef SrcCssStyleCollection As System.Web.UI.CssStyleCollection, _
ByRef DestCssStyleCollection As System.Web.UI.CssStyleCollection, _
Optional ByVal Mode As String = "REPLACE")

Dim KeyName As String
Dim KeyValue As String
Dim OldKeyValue As String

If Mode.ToUpper <> "REPLACE" Or Mode.ToUpper <> "ADD" Then
MessageBox.MessageBox("Invalid Mode, it must either be Replace or Add.",, _
"ApplyCssStyleCollectionToCssStyleCollection")
ElseIf SrcCssStyleCollection Is Nothing Then
MessageBox.MessageBox("Source CSS Style misssing",, _
"ApplyCssStyleCollectionToCssStyleCollection")
ElseIf DestCssStyleCollection Is Nothing Then
MessageBox.MessageBox("Destination CSS Style misssing",, _
"ApplyCssStyleCollectionToCssStyleCollection")
Else
If SrcCssStyleCollection.Count > 0 Then
Dim Keys(SrcCssStyleCollection.Count - 1) As String
Dim KeyCounter As Integer = 0

For Each KeyName In SrcCssStyleCollection.Keys
If KeyName <> "" Then
Keys(KeyCounter) = KeyName
KeyCounter += 1
End If
Next

If Mode.ToUpper = "REPLACE"
DestCssStyleCollection.Clear()
End If

For Each KeyName In Keys
KeyValue = SrcCssStyleCollection.Item( KeyName )

' if the key doesn't already exist, add it.
If DstCssStyleCollection(KeyName) Is Nothing Then
DestCssStyleCollection.Add(KeyName, KeyValue)
Else
DestCssStyleCollection.Item(KeyName) = KeyValue
End If
Next
End If
End If
End Sub ' End of ApplyCssStyleCollectionToCssStyleCollection


I'm using these helper functions because there aren't built in methods to convert a Style
collection to a string, via versa, and copy Style Collections to each other. Also, for some
reason you can't use the webcontrol's ApplyStyle method to copy the webcontrol's Style
setting to the MyBase.Style, which is the inherited System.Web.UI.WebControls.ListBox.

Thanks
QuestionWhere is my component's Style?!?!? Pin
howardjr8-Dec-06 8:33
howardjr8-Dec-06 8:33 
QuestionA cheeky favour to ask Pin
Waldermort8-Dec-06 8:07
Waldermort8-Dec-06 8:07 
AnswerRe: A cheeky favour to ask Pin
Bradml8-Dec-06 16:27
Bradml8-Dec-06 16:27 
GeneralRe: A cheeky favour to ask Pin
Waldermort8-Dec-06 20:57
Waldermort8-Dec-06 20:57 
GeneralRe: A cheeky favour to ask Pin
Bradml8-Dec-06 21:24
Bradml8-Dec-06 21:24 
QuestionHTA files Pin
haggenx8-Dec-06 8:05
haggenx8-Dec-06 8:05 
GeneralRe: HTA files Pin
Guffa8-Dec-06 16:44
Guffa8-Dec-06 16:44 
AnswerRe: HTA files Pin
haggenx14-Dec-06 4:02
haggenx14-Dec-06 4:02 
GeneralRe: HTA files Pin
Guffa14-Dec-06 5:37
Guffa14-Dec-06 5:37 
AnswerRe: HTA files Pin
haggenx19-Dec-06 3:25
haggenx19-Dec-06 3:25 
QuestionUsing MsgBox in my Custom Web (Server-Side) Component Pin
howardjr8-Dec-06 7:12
howardjr8-Dec-06 7:12 
QuestionWeb Search in .Net Application Pin
salaikumar8-Dec-06 0:00
salaikumar8-Dec-06 0:00 
AnswerRe: Web Search in .Net Application Pin
Bradml8-Dec-06 0:15
Bradml8-Dec-06 0:15 
QuestionHow to configure FCKEditor in PHP Pin
kumar bharat bhusanam7-Dec-06 22:16
kumar bharat bhusanam7-Dec-06 22:16 
AnswerRe: How to configure FCKEditor in PHP Pin
Bradml7-Dec-06 22:50
Bradml7-Dec-06 22:50 
Questionproblem Pin
amaneet6-Dec-06 22:40
amaneet6-Dec-06 22:40 
AnswerRe: problem Pin
Bradml6-Dec-06 22:44
Bradml6-Dec-06 22:44 

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.