一个自动生成序列的照片小程序(C#)100分。

hiweiyi2000 2004-10-15 10:42:50
我自己写的,有错,请大家调试过。

<%@ Page Language="C#"%>
<script Runat="Server">

void Button_Click(Object sender,EventArgs e)
{
string Photo_Number=txtPhoto_Number.Value;
int Photo_Number;
for(Photo_Number>0;Photo_Number<Photo_Number+33;Photo_Number++)
{
Response.Write("[IMG]http://www.psb.com.cn/news_images/dscf"+Photo_Number+".jpg[/IMG]"+"<br>");
}
}

</script>

<html>
<head><title>Photo_Number.aspx</title></head>

<body>
<form Runat="Server">

<asp:TextBox
ID="txtPhoto_Number"
Runat="Server"/>

<asp:Button
Text="提交"
OnClick="Button_Click"
Runat="Server"/>

</form>
</body>
</html>

错误提示:
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误信息: CS0117: “System.Web.UI.WebControls.TextBox”并不包含对“Value”的定义

源错误:



行 4: void Button_Click(Object sender,EventArgs e)
行 5: {
行 6: string Photo_Number=txtPhoto_Number.Value;
行 7: int Photo_Number;
行 8: for(Photo_Number>0;Photo_Number<Photo_Number+33;Photo_Number++)


源文件: C:\Inetpub\wwwroot\a\ps.aspx 行: 6
...全文
118 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hiweiyi2000 2004-10-15
  • 打赏
  • 举报
回复
还是没有搞定,再顶一下。
hiweiyi2000 2004-10-15
  • 打赏
  • 举报
回复
顶一下。
wenww 2004-10-15
  • 打赏
  • 举报
回复
关注
lql9935 2004-10-15
  • 打赏
  • 举报
回复
类型对了没有。
hiweiyi2000 2004-10-15
  • 打赏
  • 举报
回复
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误信息: CS0029: 无法将类型“string”隐式转换为“int”

源错误:



行 4: void Button_Click(Object sender,EventArgs e)
行 5: {
行 6: int Photo_Number=txtPhoto_Number.Text;
行 7: for(Photo_Number>0;Photo_Number<Photo_Number+33;Photo_Number++)
行 8: {


源文件: C:\Inetpub\wwwroot\a\ps.aspx 行: 6
孟子E章 2004-10-15
  • 打赏
  • 举报
回复
string Photo_Number=txtPhoto_Number.Text
hiweiyi2000 2004-10-15
  • 打赏
  • 举报
回复
最后自己搞定了,是显式转换数据的问题。

一定要Convert.ToInt32

<%@ Page Language="C#"%>
<script Runat="Server">

void Button_Click(Object sender,EventArgs e)
{
int Photo_Number=Convert.ToInt32(txtPhoto_Number.Text);
for(int i=0;i<=33;i++)
{
Response.Write("[IMG]http://www.psb.com.cn/news_images/dscf"+Photo_Number+".jpg

[/IMG]"+"<br>"+"<br>");
Photo_Number++;
}
}

</script>

<html>
<head><title>Photo_Number.aspx</title></head>

<body>
<form Runat="Server">

<asp:TextBox
ID="txtPhoto_Number"
Runat="Server"/>

<asp:Button
Text="提交"
OnClick="Button_Click"
Runat="Server"/>

</form>
</body>
</html>

62,243

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧