خیلی ممنون از راهنمائی های ارزنده تون.
من برای لود یوزرکنترل از این تابع اسکریپتی استفاده میکنم:
function loadUserControl(obj)
{
$.blockUI(
{
message: '<h4 style="font-family:tahoma;color:lime"><img src="' + imagePath + '/ajaxImages/loading_User.gif" /><br /><br />... درحال بارگذاري</h4>',
fadeIn: 1000,
fadeOut: 1000,
centerX: true,
centerY: true,
css:
{
border: 'none',
padding: '5px',
backgroundColor: 'transparent',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .6,
color: '#fff'
}
});
var ControlName = obj;
$.ajax({
type: "POST",
url: "Sport_InternetShetabPayment.aspx/Result",
data: "{controlName:'" + ControlName + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response)
{
$.unblockUI();
$('#result').html(response.d);
},
failure: function (msg)
{
$.unblockUI();
$('#result').html(msg);
}
// ,error: function (xhr, status, error)
// {
// $.unblockUI();
// // Boil the ASP.NET AJAX error down to JSON.
// var err = eval("(" + xhr.responseText + ")");
// // Display the specific error raised by the server (e.g. not a
// // valid value for Int32, or attempted to divide by zero).
// alert(err.Message);
// }
});
}
حالا تو اون یوزرکنترل من یه TextBox دارم که مبلغ پرداختی رو از کاربر میگیره و بعدش یه دکمه هست که بازدن اون بایستی ابتدا اطلاعات ذخیره و سپس به سایت بانک ارجاع بشه:
این کدها رو من نوشتم:
private void submitForm()
{
string bankID = "1";
string loginID = "TestMer08";
string transactionKey = "eoXaEm2LUnz2OiyQ";
string amount = txt_amount.Value;
string description = "Sample Transaction";
//string label = "Submit Payment"; // The is the label on the 'submit' button
//string testMode = "false";
string currency_code = "Rial";
//Random random = new Random();
String seq = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() +
DateTime.Now.DayOfYear.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() +
DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString();
string sequence = seq.ToString();//(random.Next(0, 1000)).ToString();
string timeStamp = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString();
string fingerprint = HMAC_MD5(transactionKey, loginID + "^" + sequence + "^" + timeStamp + "^" + amount + "^" + currency_code);
InsertPaymentReadyMelli(sequence, amount, bankID, timeStamp, fingerprint, description);
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.Write("<form name='newForm' method='post' action='https://Damoon.bankmelli-iran.com/DamoonPrePaymentController'>");
System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"x_description\" value=\"{0}\">", description));
System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"x_fp_sequence\" value=\"{0}\">", sequence));
System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"x_fp_timestamp\" value=\"{0}\">", timeStamp));
System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"x_fp_hash\" value=\"{0}\">", fingerprint));
System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"x_login\" value=\"{0}\">", loginID));
System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"x_amount\" value=\"{0}\">", txt_amount.Value));
System.Web.HttpContext.Current.Response.Write(string.Format("<input type=hidden name=\"x_currency_code\" value=\"{0}\">", currency_code));
//System.Web.HttpContext.Current.Response.Write("<as p:Button ID='btnSend' runat='server' Text='پرداخت' CssClass='sport_BtnForm' onClientClick='setAndSaveMelli()' />");
System.Web.HttpContext.Current.Response.Write("</form>");
System.Web.HttpContext.Current.Response.Write("</body>");
HttpContext.Current.Response.Write(
"<link href='../Styles/CSSSportMaster.css' rel='stylesheet' type='text/css' />" +
"<link href='../Styles/CSSSport_Login.css' rel='stylesheet' type='text/css' />" +
"<link href='../Styles/CSStxtLogin.css' rel='stylesheet' type='text/css' />" +
"<link href='../Styles/CSSSport_HorizMenu.css' rel='stylesheet' type='text/css' />" +
"<link href='../Styles/CssSport_SettleInternetShetab.css' rel='stylesheet' type='text/css' />" +
"<script src='../Scripts/jquery-1.4.4.js' type='text/javascript'></script>" +
"<script type='text/javascript'>document.forms[0].submit();</SCRIPT>");
protected void btnSend_Click(object sender, EventArgs e)
{
submitForm();
}
}
ازاونجایی که بوزرکنترل توسط جی کوئری لود میشه بصورت Htmlهست.ودسترسی به رویداد کلیک باتون در سمت سرور ممکن نیست.