javascript - Calling JQuery Function from Server (asp.net) -
in asp.net project c#, need call jquery function code behind. below function include required script:
<link rel="stylesheet" href="/fancybox/jquery.fancybox-1.3.4.css" type="text/css" media="screen" /> function showfancy(url, title, width, height) { //alert(url); $(".fancybox").fancybox({ 'width': width, 'height': height, 'autoscale': true, 'transitionin': 'elastic', 'transitionout': 'none', 'type': 'iframe', 'overlaycolor': '#000000', 'overlayopacity': 0.7, 'position': 'fixed', 'scrolling': 'yes', 'modal': false, 'target': "_parent", "onclosed": function () { window.location = window.location; } }); $('.fancybox').attr({ href: url, title: title }); $('.fancybox').click(); }
and way call aspx.cs :
protected void button1_click(object sender, eventargs e) { clientscript.registerclientscriptblock(this.gettype(), "script", "showfancy('newform.aspx?ordernumber2=' + $('#txtcontractnumber').val(), 'send', '55%', '65%');", true); }
it works fine when call function client side using input button when call server side doesn't call newform.aspx (when uncomment "alert(url);" showfancy function, alert works) . believe there 1 issue way call 'newform'. in advance time , answer.
if want execute javascript on click of button button1 need add onclick attribute in code behind. can add attribute on page_load
or onprerender
.
button1.attributes.add("onclick", "showfancy(...); return true;")
return true @ end call server side(button1_click
) of button after javascript, if need server actions.
Comments
Post a Comment