0

C# 変数 (myString) を HTML で参照しようとしています。プログラムを実行するたびに、次のエラーが発生します。

c:\Program Files\Common Files\microsoft shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\SPListWebPart\VisualWebPart1\VisualWebPart1UserControl.ascx(27): エラー CS0103: 名前 'myString' は現在のコンテキストに存在しません

これが私のコードです:

VisualWebPart1UserControl.ascx

  <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"   Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral,   PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %> 
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VisualWebPart1UserControl.ascx.cs"   Inherits="SPListWebPart.VisualWebPart1.VisualWebPart1UserControl" %>


<!DOCTYPE html>
<html>
<head>
<title></title>

<link rel="Stylesheet" type="text/css" href="c:\users\administrator\documents\visual studio 2010\Projects\SPListWebPart\SPListWebPart\VisualWebPart1\Stylesheet1.css" />
<ul id="sddm">


<script type ="text/javascript" src = "c:\users\administrator\documents\visual studio 2010\Projects\SPListWebPart\SPListWebPart\VisualWebPart1\JScript1.js"></script>
<script type ="text/C#" src="C:\Users\Administrator\Documents\Visual Studio  2010\Projects\SPListWebPart\SPListWebPart\VisualWebPart1\VisualWebPart1UserControl.ascx.cs"    ></script>


<li><a href="http://maindt" 
    onmouseover="mopen('m1');"
    onmouseout="mclosetime()"><%= %></a>
    <div id="m1" 
        onmouseover="mcancelclosetime()"
        onmouseout="mclosetime()">
    <a href="">Site 1</a>
    <a href="">Site 2</a>
    <a href="">Site 3</a>
    </div>
</li>

ここに私の VisualWebPart1.ascx.cs があります

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Administration;


namespace SPListWebPart.VisualWebPart1
{ 
    public partial class myClass : System.Web.UI.Page
    {

        public string myString = "Hello World";

        public void Page_Load(object sender, EventArgs e)
        {


        }

    }
4

0 に答える 0