嘿你可以使用两种方法Ajax Call
和__dopostback
1 __doPostback
<input type="button" id="btnSave" onclick="javascript:SaveWithParameter('Hello User')" value="click me"/>
<script type="text/javascript">
function SaveWithParameter(parameter)
{
__doPostBack('btnSave', parameter)
}
</script>
C# 代码
public void Page_Load(object sender, EventArgs e)
{
string parameter = Request["__EVENTARGUMENT"]; // parameter
// Request["__EVENTTARGET"]; // btnSave and do your work
}
2 阿贾克斯调用
function callAjaxGetJoiningDate(hashVal) {
var address = "Default.aspx";
$.ajax({
type: 'POST',
url: address,
data: { empCode: hashVal },
beforeSend: function() {
$('#ajax-panel').html('<div class="loading"><img src="images/loading.gif" alt="Loading..." /></div>');
},
success: function(data) {
// successful request; do something with the data
$('#ajax-panel').empty();
var actualData = data.trim().split('~');
$("#YourResultControl").val(actualData[1]);
},
error: function() {
// failed request; give feedback to user
$('#ajax-panel').html('<p class="error"><strong>Oops!</strong> Try that again in a few moments.</p>');
}
});
}
C#代码是
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Form["empCode"] != null)
{
//Do Work
}
}
希望对你有帮助