简体   繁体   中英

ASP.NET Web Site to Web Application conversion error

We had a Visual Studio Website project. We needed a .VBPROJ so I had to convert our Web Site Project to a Web Application Project. I followed several walktrough, did everything well for the conversion :

  • create new webapp project
  • add references
  • copy files (from website to webapp folder)
  • include them in the project
  • click "Convert to Web App".

After all that , i get three identical compilation errors, javascript related with an .ASPX page.

<%@ Page Language="VB" AutoEventWireup="false" MasterPageFile ="~/GAR.master" Inherits="GARWA._Default" Codebehind="Default.aspx.vb" %>

'TableWeekID' is not declared. It may be inaccessible due to its protection level.

<script type="text/javascript" language="javascript"> 
//Very important variable! 
var TableWeekTag = '<%=TableWeekID%>'
var DivYearSmallTableTag = '<%=DivYearSmallTable%>' 
var TableNameTag = '<%=TableNameID%>'

What's the problem here ?

Thanks

You can do it in this way.

Use a Hiddenfield control and store the server variable value in it.
One hidden field for each server variable.
And get the value into the javascript function document.getElementById()

Use the below to POPULATE the serverside input control(s) datavalues first.

ASPX SERVERSIDE CODE

svrTableWeek.Value = TableWeekID
svrDivYear.Value = DivYearSmallTable
svrTableName.Value = TableNameID

Also, if you opt for the SERVERSIDE Inputs then you need the following HTML in your ASP page

USING ASP SERVER CONTROLS FOR HIDDEN VALUES

<asp:HiddenField ID="svrTableWeek" runat="server" /> 
<asp:HiddenField ID="svrDivYear" runat="server" /> 
<asp:HiddenField ID="svrTableName" runat="server" /> 

And if you prefer CLIENTSIDE inputs then use the code below instead of ALL of the above

USING HTML (clientside) CONTROLS FOR HIDDEN VALUES

<input type="hidden" id="svrTableWeek" name="svrTableWeek" value="<%=TableWeekID%>" />
<input type="hidden" id="svrDivYear" name="svrDivYear" value="<%=DivYearSmallTable%>" />
<input type="hidden" id="svrTableName" name="svrTableName" value="<%=TableNameID%>" />

Finally regardless of which of the two above methods you choose, now your ready to re-use those values in your clientside javascript

CLIENT SIDE SCRIPT ROUTINES

<script type="text/javascript" language="javascript"> 
//Very important variable! 
var sTableWeek = document.getElementById('svrTableWeek').value;
var sDivYear = document.getElementById('svrDivYear').value;
var sTableName = document.getElementById('svrTableName').value;

It seems a bit long winded I know, but it should work without issues.

Try global replacing all of the "~/GAR with "GAR . I just converted a Web Site to a Web App, had similar odd errors, all because the virtual reference to the master page files was no longer correct. My first indicator was a DIV ID that wasn't seen in a code-behind file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM