Solved

Site wide variable

Posted on 2009-05-04
8
218 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
 

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

910 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now