Showing posts with label setting. Show all posts
Showing posts with label setting. Show all posts

Saturday, March 31, 2012

Themes not working sometimes.

I am setting the src of a Iframe in the page load like this:
fraContent.Attributes.Item("src") = "Splash.aspx"
and sometimes the themes do not work. The page displays in the browser but
the themes are not applied. The <link ... is on the page when I look at the
soruce.
Any Ideas.
Thank you,
--
JerryHello Jerry,
I do not have your source code to test on directly. But here are some
suggestions that, I think, deserve your trial.
1. Does the "<link _" links to the correct theme page when the themes are
not applied? Please pay attention to the relative path. In my best guess,
the theme page cannot be loaded because the relative path to the page is
not correct.
2. Is the line fraContent.Attributes.Item("src") = "Splash.aspx" inside the
if statement: if (!Page.IsPostBack) { _ }?
If that, when the page post-back occurs, the line
fraContent.Attributes.Item("src") = "Splash.aspx" will not be executed in
the Page_Load event handler.
We can debug the site in Visual Studio, set a breakpoint on
fraContent.Attributes.Item("src") = "Splash.aspx" and see if it is executed
every time when we need to load the theme page.
3. When the theme page cannot be loaded, what is the browser? As far as I
know, some browsers do not support html tags very well.
By the way, since ASP.NET 2.0, a new feature "Theme & Skin" has been
supported by ASP.NET. If your theme pages only contain style information,
I'd suggest using ASP.NET Theme, which is much easier to accomplish the
task. For more information about "Theme and Skin" in ASP.NET, please refer
to:
ASP.NET Themes and Skins Overview
http://msdn2.microsoft.com/en-us/library/ykzx33wh.aspx
How to: Apply ASP.NET Themes Programmatically
http://www.15seconds.com/issue/040105.htm
Code in Style with ASP.NET Themes.
http://www.15seconds.com/issue/040105.htm
Hope it helps.
Regards,
Jialiang Ge (jialge@.online.microsoft.com, remove 'online.')
Microsoft Online Community Support
========================================
==========
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...t/default.aspx.
========================================
==========
This posting is provided "AS IS" with no warranties, and confers no rights.
Hello Jerry,
Sorry for the incorrect link to the article "How to: Apply ASP.NET Themes
Programmatically".
The link should be:
http://msdn2.microsoft.com/en-us/library/tx35bd89.aspx
If you have any other concerns or need anything else, please feel free to
let me know.
Regards,
Jialiang Ge (jialge@.online.microsoft.com, remove 'online.')
Microsoft Online Community Support
========================================
=========
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
========================================
=========
This posting is provided "AS IS" with no warranties, and confers no rights.
Jialiang,
Thank you for your reply. The problem only occurs SOME of the time so all
the links are about appying the themes and if the code was not correct the
themes would not be there ALL of the time not just SOME of the times.
Anyway.
I have fixed the problem. This does not explain why the problem occured in
the first place. I placed a system.threading.thread.sleep line in the
LoadComplete event of the page. this seemed like the same problem solved by
the waitForEvents in window forms.
Have you seen any of this kind of problem.
Thank you
--
Jerry
"Jialiang Ge [MSFT]" wrote:

> Hello Jerry,
> Sorry for the incorrect link to the article "How to: Apply ASP.NET Themes
> Programmatically".
> The link should be:
> http://msdn2.microsoft.com/en-us/library/tx35bd89.aspx
> If you have any other concerns or need anything else, please feel free to
> let me know.
> Regards,
> Jialiang Ge (jialge@.online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
> ========================================
=========
> When responding to posts, please "Reply to Group" via your newsreader
> so that others may learn and benefit from your issue.
> ========================================
=========
> This posting is provided "AS IS" with no warranties, and confers no rights
.
>

Thursday, March 22, 2012

Thought this would be simple

Thought I would work on setting certain UI elements dynamically. Sounded like an easy task until now. Any ideas how to resolve this error?

The ASPX page:

<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false" Codebehind="DynamicallyBuildTables.aspx.vb" Inherits="BookChp5a.DynamicallyBuildTables"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>DynamicallyBuildTables</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<P>
Rows:
<asp:TextBox id="txtRows" runat="server" /> Cols:
<asp:TextBox id="txtCols" runat="server" /></P>
<P>
<asp:CheckBox id="chkBorder" runat="server" Text="Put border around Cells"></asp:CheckBox></P>
<P>
<asp:DropDownList id="ddl1" runat="server"></asp:DropDownList>
</P>
<P>
<asp:Button id="cmdCreate" runat="server" Text="Create"></asp:Button><BR>
</P>
<P>
<asp:Table id="Tbl1" runat="server">
<asp:TableRow ID="row" Runat="server">
<asp:TableCell id="cell" Runat="server" Text="A Test RowSpan">
<!-- Instead of using the Text property, you could add other
ASP.NET control tags here. --></asp:TableCell>
</asp:TableRow>
</asp:Table>
</P>
</form>
</body>
</HTML>


The code behind file:

Public Class DynamicallyBuildTables
Inherits System.Web.UI.Page
' Inherits System.Web.UI.WebControls
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected WithEvents txtRows As System.Web.UI.WebControls.TextBox
Protected WithEvents txtCols As System.Web.UI.WebControls.TextBox
Protected WithEvents chkBorder As System.Web.UI.WebControls.CheckBox
Protected WithEvents cmdCreate As System.Web.UI.WebControls.Button
Protected WithEvents Tbl1 As System.Web.UI.WebControls.Table
Protected WithEvents ddl1 As System.Web.UI.WebControls.DropDownList

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If IsPostBack = False Then
Tbl1.Visible = False
ddl1.Items.Add("Dashed")
ddl1.Items.Add("Dotted")
ddl1.Items.Add("Doubled")
ddl1.Items.Add("Groove")
ddl1.Items.Add("Inset")
ddl1.Items.Add("None")
ddl1.Items.Add("NotSet")
ddl1.Items.Add("Outset")
ddl1.Items.Add("Ridge")
ddl1.Items.Add("Solid")
Else
Tbl1.Visible = True
End If
' Tbl1.BorderStyle = BorderStyle.Inset
Tbl1.BorderWidth = Unit.Pixel(1)
End Sub

Private Sub cmdCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCreate.Click
'Remove all current rows and cells.
'This would not be necessary if you set
'EnableViewState = False.
Tbl1.Controls.Clear()
Dim strRows As String = txtRows.Text
Dim strCols As String = txtCols.Text
Dim strBorder As String = "BorderStyle." & ddl1.SelectedItem.Text
Dim i, j As Integer
For i = 1 To Val(strRows)
'Create a new tablerow object.
Dim rowNew As New TableRow
'put the new tablerow into the table object.
Tbl1.Controls.Add(rowNew)
For j = 1 To Val(strCols)
'Create a new TableCell object.
Dim cellNew As New TableCell
'***************************** standard text
'cellNew.Text = "Example Cell (" & i.ToString() & ","
'cellNew.Text &= j.ToString() & ")<br />"
'*****************************
'***************************** Added as objects
Dim lblNew As New Label
Dim imgNew As New System.Web.UI.WebControls.Image
imgNew.ImageUrl = "/images/smile.gif"
lblNew.Text = "hello"
cellNew.Controls.Add(lblNew)
cellNew.Controls.Add(imgNew)
'*****************************

If chkBorder.Checked Then
' Not working accurately, but dows show how to
' dynamically set border style.
txtCols.Text = strBorder
cellNew.BorderStyle = strBorder 'Bombs right here
cellNew.BorderWidth = Unit.Pixel(4)
End If
'Put the TableCell in the TableRow.
rowNew.Controls.Add(cellNew)
Next
Next
End Sub
End Class


Also, Is there a way to populate the ddl1.items.add("") list within the code and not hard coding?Also, Is there a way to populate the ddl1.items.add("") list within the code and not hard coding?

I'm not sure what you're trying to do.
I'm not sure what you're trying to do.

Would help if I explained it more. Sorry about that. :blush:

I am trying to dynamicaly assign the BorderStyle from the value in a string variable. The following line blows up:

cellNew.BorderStyle = strBorder 'Bombs right here

In addition to that, when you manually assign "BorderStyle." intellisense pops up with the listed values:

Dashed
Dotted
Doubled
Groove
Inset
None
NotSet
Outset
Ridge
Solid

I want to capture those values and place them into a DropDownList with out having to hard code. Instead of doing it like this:

ddl1.Items.Add("Dashed")

Can I code it to auto populate those values?

Any ideas?