私のhtmlコードは
<script type="text/jscript">
function ajaxcall() {
$.ajax({
type: "POST",
url: "index.aspx/lvimgclick",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ }),
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 string lvimgclick()
{
return "hi";
}
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";
lvlblhd.CssClass = "detailheader";//label
lvlblsubhd.CssClass = "detailsubheader";//label
lvtd.BgColor = "#7e65a9";//td
lvlblhd.Text = "<img src='images/spacer.gif' height='8px' width='5px' /><br/>Wake up";
lvlblsubhd.Text = " to a fragrant day..";
lvlbl.Text = "A beautifully fragrance residence";
}
私が欲しいのは:
[WebMethod]
public static string lvimgclick()
{
lvimg1_Click(null, null);
return "hi";
}
また
[WebMethod]
public static void lvimgclick()
{
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";
lvlblhd.CssClass = "detailheader";//label
lvlblsubhd.CssClass = "detailsubheader";//label
lvtd.BgColor = "#7e65a9";//td
lvlblhd.Text = "<img src='images/spacer.gif' height='8px' width='5px' /><br/>Wake up";
lvlblsubhd.Text = " to a fragrant day..";
lvlbl.Text = "A beautifully fragrance residence";
}
私は何をしなければなりませんか?lvimg1_Click(null, null);も使用する必要があります。およびlvlink1.CssClass = "lv-under1"; Webメソッドではない多くの機能で
私は新しいので、もっと多くの情報が必要な場合はお知らせください