473,322 Members | 1,610 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,322 software developers and data experts.

Public string

Hi,

THe following code (in c# has been provided to me as an answer in another
question).. however I can work out where to place the code.

I need a public string so that i can access a string value in the HTML
source of a page..

The public sting is below.. So this go in a class file? the code behind
file? or a global module?

Thanks
public string VideoUrl

{

get

{

return "http://localhost/1.avi";

}

}
Aug 5 '06 #1
6 2886
"Aussie Rules" <Au*********@nospam.nospamwrote in message
news:O$**************@TK2MSFTNGP02.phx.gbl...
THe following code (in c# has been provided to me as an answer in another
question).. however I can work out where to place the code.

I need a public string so that i can access a string value in the HTML
source of a page..

The public sting is below.. So this go in a class file? the code behind
file? or a global module?
There's really no such thing as a "global module" in .NET, but the effect is
achievable thus:

public static class CGlobal
{
public static string VideoUrl = "http://localhost/1.avi";
}

Then in your HTML:

<asp:Label ID="lblTest" runat="server" />

And finally in your codefile:

lblTest.Text = CGlobal.VideoUrl;

Of course, the OO purists will tell you that the above is absolutely
appalling... ;-)
Aug 5 '06 #2
Hi,
Thanks for your reply. I have tried to convert this to VB,but cann't figure
it out....

Also does the declaration of the of the class occur the code behind file for
the html page, or elsewhere?

Thanks
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:eU**************@TK2MSFTNGP03.phx.gbl...
"Aussie Rules" <Au*********@nospam.nospamwrote in message
news:O$**************@TK2MSFTNGP02.phx.gbl...
>THe following code (in c# has been provided to me as an answer in another
question).. however I can work out where to place the code.

I need a public string so that i can access a string value in the HTML
source of a page..

The public sting is below.. So this go in a class file? the code behind
file? or a global module?

There's really no such thing as a "global module" in .NET, but the effect
is achievable thus:

public static class CGlobal
{
public static string VideoUrl = "http://localhost/1.avi";
}

Then in your HTML:

<asp:Label ID="lblTest" runat="server" />

And finally in your codefile:

lblTest.Text = CGlobal.VideoUrl;

Of course, the OO purists will tell you that the above is absolutely
appalling... ;-)

Aug 5 '06 #3
"Aussie Rules" <Au*********@nospam.nospamwrote in message
news:O9**************@TK2MSFTNGP03.phx.gbl...
Thanks for your reply. I have tried to convert this to VB,but cann't
figure it out....
Should have said you needed it in VB.NET... This is my best guess, as I
don't use VB.NET at all...

Public Shared Class CGlobal
Public Shared VideoUrl As String = "http://localhost/1.avi"
End Class
Also does the declaration of the of the class occur the code behind file
for the html page, or elsewhere?
??? There is no declaration of the class...
Aug 5 '06 #4
You can put the class in code behind or create a separate class file, the
compiler wont care.

"Mark Rae" wrote:
"Aussie Rules" <Au*********@nospam.nospamwrote in message
news:O9**************@TK2MSFTNGP03.phx.gbl...
Thanks for your reply. I have tried to convert this to VB,but cann't
figure it out....

Should have said you needed it in VB.NET... This is my best guess, as I
don't use VB.NET at all...

Public Shared Class CGlobal
Public Shared VideoUrl As String = "http://localhost/1.avi"
End Class
Also does the declaration of the of the class occur the code behind file
for the html page, or elsewhere?

??? There is no declaration of the class...
Aug 5 '06 #5
You can create modules in VB.NET
Create a class and rename "Class" to module

Indeed no eq. in c# and public static class is required as it's functions
must be set to static as well.
"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:%2****************@TK2MSFTNGP04.phx.gbl...
"Aussie Rules" <Au*********@nospam.nospamwrote in message
news:O9**************@TK2MSFTNGP03.phx.gbl...
>Thanks for your reply. I have tried to convert this to VB,but cann't
figure it out....

Should have said you needed it in VB.NET... This is my best guess, as I
don't use VB.NET at all...

Public Shared Class CGlobal
Public Shared VideoUrl As String = "http://localhost/1.avi"
End Class
>Also does the declaration of the of the class occur the code behind file
for the html page, or elsewhere?

??? There is no declaration of the class...

Aug 5 '06 #6
Thanks all.. got it sorted...
"Neverlyn" <br******@powerplay.auz.netwrote in message
news:48**********************************@microsof t.com...
You can put the class in code behind or create a separate class file, the
compiler wont care.

"Mark Rae" wrote:
>"Aussie Rules" <Au*********@nospam.nospamwrote in message
news:O9**************@TK2MSFTNGP03.phx.gbl...
Thanks for your reply. I have tried to convert this to VB,but cann't
figure it out....

Should have said you needed it in VB.NET... This is my best guess, as I
don't use VB.NET at all...

Public Shared Class CGlobal
Public Shared VideoUrl As String = "http://localhost/1.avi"
End Class
Also does the declaration of the of the class occur the code behind
file
for the html page, or elsewhere?

??? There is no declaration of the class...

Aug 5 '06 #7

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

Similar topics

0
by: john bailo | last post by:
I am attempting to create a c# program to iterate through the messages in an Outlook/Exchange public folder and extract the headers. My apologies to the VB/VBA groups, but you seem to have more...
1
by: Erik Tamminga | last post by:
Hi, I'm totally bluffed: how can a 'public const string name = "myname";' ever evaluate to null? I have the following class: public class MIB2 { public const string org = "1.3";
7
by: John Grandy | last post by:
make a call to XML Web Service WebMethod ... returns object myArray with no error ... myArray contains objects of type StringKeyStringValue runtime error occurs on accessing properties of...
1
by: May | last post by:
greetings, i came across a function while browsing thru the net. This function is created in a component. what i am curious to know is, is this the correct way to create a function using: Public...
4
by: Webster | last post by:
Hello, Just wondering what's better programming style; to use public variables in a class or to use private/protected variables and then expose them via properties? For example:...
4
by: funVB2005fun | last post by:
I am not quite sure what I am getting into but I would like to have a loop that read from a flat file to create some public properties in a class. I am going after this to try and create more...
9
by: Stefan De Schepper | last post by:
Should I use: Private m_Name As String Public Property Name() As String Get Return m_Name End Get Set(ByVal Value As String) m_Name = Value
0
by: Pilotflyhigh | last post by:
Hi, Please help. I have a class called Test public class Test { //This is my constructor public Test(string Code) { _code = Code; }
4
by: =?Utf-8?B?QXJseW5fTA==?= | last post by:
I have a Namespace compiling to a DLL. It contains 2 classes and 10 structs all typed as public and it worked. When I added an additional public struct the added public struct cannot be accessed...
2
by: fgh.vbn.rty | last post by:
Hi, I'm not sure if i'm asking the question correctly but anyway here it is. Say I have 3 classes - class A, class B, class R. 1) A and B are the building blocks and R is like a repository...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.