帮忙看看,找不到变量
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="hyfrcTest.aspx.cs" Inherits="views_v40_hyfrc_hyfrcTest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<%
String oldValue = Request.Params["oldValue"];
String encryValue ="";
if (oldValue != null)
{
encryValue = com.umpay.api.util.SignUtil.RSAEncrypt(oldValue);
}
%>
</head>
<body>
<form id="form1" action="hyfrcTest.aspx" runat="server">
<div>
<table>
<tr>
<td>请输入要加密的值:</td>
<td><input type="text" name="oldValue" value="<% =Request.Params["oldValue"]%>"/></td>
</tr>
<tr>
<td>加密后的值:</td>
<td><textarea name="encryValue" cols="5" rows="2"><%= encryValue%> </textarea></td>
</tr>
<tr>
<th nowrap="nowrap"></th>
<td nowrap="nowrap"><div ><input type="submit" value="提交" /></div></td>
</tr>
</table>
</div>
</form>
</body>
</html>
“/MerPay30”应用程序中的服务器错误。
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误消息: CS0103: 当前上下文中不存在名称“encryValue”
源错误:
行 29: <tr>
行 30: <td>加密后的值:</td>
行 31: <td><textarea name="encryValue" cols="5" rows="2"><%= encryValue%> </textarea></td>
行 32: </tr>
行 33: <tr>
源文件: d:\cworkspace\MerPay40\MerPay30\views\v40\hyfrc\hyfrcTest.aspx 行: 31
显示详细的编译器输出:
显示完整的编译源:
[解决办法]
那就是你没有encryValue这个组件,你只是赋值了HTML代码,但界面 与其不符
[解决办法]
对,但是我还是建议你采用Code Behind方式,不要把服务端代码也写到aspx上
[解决办法]
定义的时候加上public试试public String encryValue ="";
这样吗?
这样完全不行
嗯,<% %>表示代码块,这样确实是不行的,
你还是把这个定义放到aspx.cs里吧
[解决办法]
看似好高级的样子, 下面这段代码会生成到哪去呢? 类中? 方法中? 好像都不对啊- -
<%
String oldValue = Request.Params["oldValue"];
String encryValue ="";
if (oldValue != null)
{
encryValue = com.umpay.api.util.SignUtil.RSAEncrypt(oldValue);
}
%>
[解决办法]
public string name = "sfasf";
protected void Page_Load(object sender, EventArgs e)
{
name = "ooooo";
}
是可以输出ooooo的
我想你肯定是在Load之外对其赋值操作,那么由于页面的解析执行顺序,你的赋值操作将无效