Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Site wide variable

Posted on 2009-05-04
8
220 Views
Last Modified: 2013-11-26
I need to set a path sitewide on web site load so that I can use an images path whatever page is loaded.

All pages reference a Masterpage by the way.
0
Comment
Question by:lrbrister
  • 5
  • 3
8 Comments
 
LVL 1

Expert Comment

by:chuckdsc
ID: 24295377
in VB.Net create a module which is accessible across the solution and create a public variable to store the value.

Module Module1
    Public moduleinteger As Integer
End Module


in C# create a public static class and create a public static variable to store the values which can be accessed anywhere in the project

namespace ModuleTest
{
        public static Module1
        {
                public static int moduleinteger;
        }
}
0
 

Author Comment

by:lrbrister
ID: 24295906
chuckdsc:


I need to set a variable as follows

dim _path as string = ""
_path="http://seg.mydomain.com/images"

Then be able to use it on a page with
<%#_path%> ---not sure about the syntax on that line
0
 
LVL 1

Expert Comment

by:chuckdsc
ID: 24296460
lrbrister:

correct me otherwise,

 let me assume you are using an image control
then you can do it like this

dim _path as string = "http://seg.mydomain.com/images"
Image1.ImageUrl = _path & "<image>"

0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:lrbrister
ID: 24296559
chuckdsc:

That's correct.  I need that _path to be available on any page.

However...the datasource is nopt called from code behind but with a connection string.

So the actual image on the aspx page looks like this

<img src="http://seg.mydomain.com/imagesCMS/large/<%#Eval("ImageSrc")%>" alt="" width="170px" />
0
 
LVL 1

Expert Comment

by:chuckdsc
ID: 24296786
lrbrister:

Try changing the src like this

#Eval("imgfil", "http://seg.mydomain.com/imagesCMS/large/{0}.jpg")

let me know how it works
0
 
LVL 1

Expert Comment

by:chuckdsc
ID: 24296792
#Eval("ImageSrc", "http://seg.mydomain.com/imagesCMS/large/{0}.jpg")
0
 

Author Comment

by:lrbrister
ID: 24314003
chuckdsc
In your answer at the top you have
dim _path as string = "http://seg.mydomain.com/images"

how do I make that _path load at login and be available on every page in the site?
0
 
LVL 1

Accepted Solution

by:
chuckdsc earned 500 total points
ID: 24322266
lrbrister:

in VB.Net, create a public module, it can be accessed anywhere in the application as it creates a global scope for the variables declared with public

refer the following MSDN article

http://msdn.microsoft.com/en-us/library/aaxss7da.aspx


0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question