473,387 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

.ascx file question

Hi all,

Still very new to ASP.Net so please bare with me.

I have created several .ascx controls which I have dragged and dropped onto
my page in a table, looks very nice - each of the controls contains HTML
code which is re-used across several pages.

One on the controls places a navigation bar across the page and should tell
the user where they are etc.

When I clicked on 'view code' in VS to add some IF...THEN's for checking the
page they are on against my list of pages they could be on - I received an
error message about the positioning of my code....I am a bit lost...

Here's the code from the control as it is now -working -without what I'd
like to add...

Public Class GreyBar
Inherits System.Web.UI.UserControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
'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
End Class

And here's the HMTL view of the page :

<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="GreyBar.ascx.vb" Inherits="eNotifications.GreyBar"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td align="right" bgColor="#dddddd"><font
class="greybarHeadingText"><b>PAGE NAME HERE<b>&nbsp;</font></td>
</tr>
</table>
What I want to do is run something like this (this is probably what I'd have
done in regular ASP)...

If UCase(Request.ServerVariables("SCRIPT_NAME")) = "NOTIFICATION.ASPX" Then

strPageName = "Submit Notification"

End If

Obviously I would have more of these for the other pages too, but this would
then give me the text I want in a variable to then use above perhaps in the
form of :

<%=strPageName%>

etc

But I'm not sure where to place this code - surely it should go into the
..ascx file - in the code behind (.vb) file for it?

Any help would be appreciated...

Regards

Rob
Nov 18 '05 #1
1 1207
"Rob Meade" wrote...
But I'm not sure where to place this code - surely it should go into the
.ascx file - in the code behind (.vb) file for it?


I have managed to get it to work by adding the following into my .vb file
for the .ascx

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

' Declare variables

Dim aScriptName As Array
Dim strScriptName As String

' Populate script name variable
strScriptName = UCase(Request.ServerVariables("SCRIPT_NAME"))

' Create an array of script name parts
aScriptName = Split(strScriptName, "/")

' Set our script name variable to equal the last item in the array
strScriptName = aScriptName(UBound(aScriptName))

' Begin our page name testing routine

If strScriptName = "LOGOUT.ASPX" Then

lblPageName.Text = "Log Out"

ElseIf strScriptName = "NOTIFICATION.ASPX" Then

lblPageName.Text = "Submit Notification"

End If

End Sub
Seems to work nicely, but if anyone spots any mistakes, ie, I'm going about
this the wrong way please let me know.

Thanks

Rob
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rob Meade | last post by:
Hi all, I have just put together our organisations 'template' for our web applications and have created 7 .ascx files which when dropped into my template file work perfectly...however, I have a...
2
by: Jon Spivey | last post by:
Hi, probably missing something obvious here. I have a user control hot10.ascx which just contains a repeater, a code behind file hot10.ascx.vb which fills the repeater from a datareader and a...
4
by: ChrisB | last post by:
Hi - I'm just trying to figure out what would be involved with deploying a simple HTML update to an ASCX file. Where there were no changes to the code behind (compiled code), to deploy this to...
6
by: tshad | last post by:
I have an ascx file I am using to include my logos and heading information for all my pages. It was working fine up until now. I decided to set up an admin folder inside of my main folder and...
0
by: damiensawyer | last post by:
Hello all, I'm very new to all of this. I have a theme and a skin (the standard ones). I have a standard master page which is holding a custom ascx which has a treeview in it. Can someone...
3
by: Steven Nagy | last post by:
Hi all, ASP.NET : Framework 2.0 - C# A recent addition to my code generater will create GridView's and ObjectDataSource's in a control (ASCX). So the code gen creates an ascx, ascx.cs,...
2
by: TARUN | last post by:
I have a question about declaring the Global.ascx: In VS.NET I create a Solution, and there are 4 projects under it. They are put under 4 folders, but web pages would be called across the 4...
2
by: royend | last post by:
How may I include a .ascx-file into my C#-file? I have read somewhere that the usual include is no longer supported for ASP.NET C#, but is there someway around this? The file to be included is...
0
by: =?Utf-8?B?R3JlZw==?= | last post by:
I have an ascx file that dynamically loads other ascx files. each of these ascx files need to perform client callback functions. It seems that when i try and break out all the javascript code into...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.