新手请教,请帮忙看看我写的代码,一点击按钮就显示缺少对象

simmlove 2010-09-14 08:15:22
<input type="button" runat="server" id="btn" onclick="clickk()" value="将此图片设为背景" />

这里出了问题



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Runtime.InteropServices;

public partial class wallpaper : System.Web.UI.Page
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);

protected void Page_Load(object sender, EventArgs e)
{

}

public void clickk()
{
//string filepath = Path.GetFileName(MapPath("Images/豌豆背景.bmp"));
int nResult;
nResult = SystemParametersInfo(20, 1, @"~/Images/豌豆背景.bmp", 0x1 | 0x2);
if (nResult == 0)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('没有更新成功!';)</script>");
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('更新成功!';)</script>");
}
}
}
...全文
102 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
simmlove 2010-09-14
  • 打赏
  • 举报
回复
我是要改windows桌面背景哦……:(
天下如山 2010-09-14
  • 打赏
  • 举报
回复
function tst()
{
var t=document.getElementById("");
t.style.backgroundImage="url("+bgimg.src+")"; //相对路径
}
simmlove 2010-09-14
  • 打赏
  • 举报
回复
……呃 我还是新手 还没学ajax 5555~
那要是用js写方法 怎么写才能实现点击按钮换桌面背景呢?谢谢你
wuyq11 2010-09-14
  • 打赏
  • 举报
回复
通过ajax 调用web services等实现
simmlove 2010-09-14
  • 打赏
  • 举报
回复
不能用input button的onclick事件调用public void clickk()这个方法吗?
wuyq11 2010-09-14
  • 打赏
  • 举报
回复
onclick="clickk()"
function clickk()
{

}
wzlblair 2010-09-14
  • 打赏
  • 举报
回复
我记得HTML input 标签的服务端onclick事件,好像是onserverclick

还有SystemParametersInfo这个也不太清楚是什么 呵呵
simmlove 2010-09-14
  • 打赏
  • 举报
回复
大家帮帮我,,谢谢!~

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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