Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use include files with ASP.NET

Status
Not open for further replies.

whykeepderegingme

Programmer
May 17, 2005
6
CA
hey, before i get deregistered randomly for the 3rd time, I have a question.

I am converting a system from ASP to ASP.NET. Our current system uses include files extensively. For example, each page includes LanguageManagerINC.asp. In LanguageManagerINC.asp, we include LanguageVars.asp, which contains a set of variable declarations, and we look at a cookie to see if language is set to 0 or 1 (english/french), and include the appropriate definition file, LanguageEnglish.asp or LanguageFrench.asp.

So,

LanguageManagerINC.asp looks like this:

<%
Dim strLang
strLang = Request.Cookies("language")
%>

<!-- #include file="ve_LanguageManager.asp" -->
<%If strLang = "1" Then%>
<!-- #include file="ve_LanguageFrench.asp" -->
<%Else%>
<!-- #include file="ve_LanguageEnglish.asp" -->
<%End If%>




LanguageVars looks like this:

<%
dim userName
dim password
...
%>

LanguageEnglish looks like this:

<%
userName = "Enter username here"
password = "Enter password here"
%>

Then, those variables are used in the pages as labels, so a page might have <%=userName%> in it, whose value will depend on whether the cookie stored english or french as the preferred language.

Now we are using C#, and I'm lost as to where to start. I have got it sort of working with a user control, I can use <%=myControl.userName%>, but I can't use it in conjunction with a server control, such as an asp:Button. I thought I would be able to do:

<asp:Button ID="submit" Runat="server" Text=<%=myControl.userName%>></asp:Button>

But this gives me an error, saying I can't use <% %> with a server control. GRRRRRRRRRRRRR...
 
You need to add this in the page load event in code behind.

submit.Text = myControl.userName
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top