前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Main_Invoice_Default" %>
<!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>Jquery调用后台的RadioButtonList_SelectedIndexChanged事件</title>
<script type="text/jscript" src="../../js/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#btnInvoke").click(function () {
<span style="color:#ff0000;">$('input[name=rblType]').get(0).click();
</span> });
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" id="btnInvoke" value="调用" />
<asp:RadioButtonList ID="rblType" runat="server" RepeatDirection="Horizontal" AutoPostBack="true" OnSelectedIndexChanged="rblType_SelectedIndexChanged">
<asp:ListItem Value="0" Text="To China OC office"></asp:ListItem>
<asp:ListItem Value="1" Text="To Germany"></asp:ListItem>
</asp:RadioButtonList>
</div>
</form>
</body>
</html>
后台代码:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Main_Invoice_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void rblType_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Write("这是Jquery调用后台的SelectedIndecChanged事件");
}
}
这篇博客探讨了如何利用Jquery在前端操作RadioButtonList,并触发后台的SelectedIndexChanged事件。详细介绍了前后台代码实现这一功能的方法。
2718

被折叠的 条评论
为什么被折叠?



