Public string

  • Thread starter Thread starter Aussie Rules
  • Start date Start date
A

Aussie Rules

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";

}

}
 
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... ;-)
 
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
 
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...
 
You can put the class in code behind or create a separate class file, the
compiler wont care.
 
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.
 
Thanks all.. got it sorted...


Neverlyn said:
You can put the class in code behind or create a separate class file, the
compiler wont care.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top