我有服务器控件说链接按钮,我想在web 方法功能中使用该控件,并在一个函数中使用该服务器控件(链接按钮),这不应该是 web 方法。
HTML代码是
<script type="text/jscript">
function ajaxcall() {
$.ajax({
type: "POST",
url: "index.aspx/lvimgclick",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ value: "test" }),
dataType: "json",
});
};
</script>
<img src='images/img1.jpg' onclick='return ajaxcall();' /> // calling script
<asp:LinkButton ID="lvlink1" OnClick="lvimg1_Click" CssClass="lv-under" runat="server" >
<asp:Image ID="lvimg1" runat="server" ImageUrl="~/images/spacer.gif" />
<asp:LinkButton ID="lvlink2" OnClick="lvimg2_Click" CssClass="lv-under" runat="server" >
<asp:Image ID="lvimg2" runat="server" ImageUrl="~/images/spacer.gif" />
<asp:LinkButton ID="lvlink3" OnClick="lvimg3_Click" CssClass="lv-under" runat="server" >
<asp:Image ID="lvimg3" runat="server" ImageUrl="~/images/spacer.gif" />
.cs 代码
[WebMethod]
public static void lvimgclick()
{
}
protected void lvimg1_Click(object sender, EventArgs e)
{
lvlink1.CssClass = "lv-under1"; // Another class
lvimg1.ImageUrl = "~/images/1.jpg";
lvlink2.CssClass = "lv-under";
lvimg2.ImageUrl = "~/images/spacer.gif";
lvlink3.CssClass = "lv-under";
lvimg3.ImageUrl = "~/images/spacer.gif";
}
我想要的是:
[WebMethod]
public static void lvimgclick()
{
lvimg1_Click(null, null);
}
或者
[WebMethod]
public static void lvimgclick()
{
lvlink1.CssClass = "lv-under";
lvimg1.ImageUrl = "~/images/1.jpg";
lvlink2.CssClass = "lv-under";
lvimg2.ImageUrl = "~/images/spacer.gif";
lvlink3.CssClass = "lv-under";
lvimg3.ImageUrl = "~/images/spacer.gif";
}
我该怎么办?
我还必须使用lvimg1_Click(null, null); 和lvlink1.CssClass = "lv-under1"; 在许多其他不是网络方法的功能上