Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 23rd, 2012  |  syntax: None  |  size: 5.48 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. call javascript function from c# not working
  2. function afficherMessageInfo( id, message) {
  3.  
  4.  
  5.     //Get the A tag
  6.     alert('executing the client code');
  7.  
  8.     //Get the screen height and width
  9.     var maskHeight = $(document).height();
  10.     var maskWidth = $(window).width();
  11.  
  12.     //Set heigth and width to mask to fill up the whole screen
  13.     $('#mask').css({'width':maskWidth,'height':maskHeight});
  14.  
  15.     //transition effect    
  16.     $('#mask').fadeIn(500);
  17.     $('#mask').fadeTo("slow",0.8);  
  18.  
  19.     //Get the window height and width
  20.     var winH = $(window).height();
  21.     var winW = $(window).width();
  22.  
  23.     //Set the popup window to center
  24.     $(id).css('top',  winH/2-$(id).height()/2);
  25.     $(id).css('left', winW/2-$(id).width()/2);
  26.  
  27.     //transition effect
  28.     $(id).fadeIn(1000);
  29.  
  30.  
  31.  
  32.  
  33. }
  34.  
  35. $('.window .close').live("click", function (event) {
  36. //Cancel the link behavior
  37. event.preventDefault();
  38. $('#mask').hide();
  39. $('.window').hide();
  40. });
  41.  
  42. //if mask is clicked
  43. $('#mask').live("click", function (event) {
  44.   $(this).hide();
  45.   $('.window').hide();
  46. });
  47.        
  48. void BtnEnregistrer_btnClick(object sender, EventArgs e)
  49.     {
  50.         string id = "#info";
  51.         string messageInfo = "le dossier a été crée avec succès";
  52.  
  53.  
  54.         string script = String.Format("afficherMessageInfo({0},{1})", id, messageInfo);
  55.         this.Page.ClientScript.RegisterStartupScript(this.GetType(),
  56.         "afficherMessageInfo", script, true);
  57.  
  58.     }
  59.        
  60. <script src="../Scripts/jquery.js" type="text/javascript"></script>
  61. <script src="popupScript.js" type="text/javascript"></script>
  62.  
  63. </head>
  64.  
  65. <body>
  66.  <form id="form1" runat="server">
  67. <div id="boxes">
  68. <!-- information -->
  69.     <div id="info" class="window" style="display:none;">
  70.         <div class="info_title">
  71.             <div class="pop_title">Information</div>
  72.             <div class="close_image"><a href="#"class="close"/><img src="images/popups/close.jpg" border="0" /></a></div>
  73.         </div>
  74.         <div class="pop_content">
  75.             <div class="pop_message">Etiam vel nisl ante. Mauris congue sodales risus ac cele risque Etiam vel nisl ante.Etiam vel nisl ante.</div>
  76.             <div align="right"><input name="" type="button" value="OK" class="info_bt"/></div>
  77.         </div>
  78.     </div>
  79. <!-- Alerte -->
  80.     <div id="alerte" class="window" style="display:none;">
  81.         <div class="alerte_title">
  82.             <div class="pop_title">Alerte</div>
  83.             <div class="close_image"><a href="#"class="close"/><img src="images/popups/close.jpg" border="0" /></a></div>
  84.         </div>
  85.         <div class="pop_content">
  86.             <div class="pop_message">Etiam vel nisl ante. Mauris congue sodales risus ac cele risque Etiam vel nisl ante.Etiam vel nisl ante.</div>
  87.             <div align="right"><input name="" type="button" value="OK" class="alerte_bt"/></div>
  88.         </div>
  89.     </div>
  90. <!-- validation -->
  91.     <div id="validation" class="window" style="display:none;">
  92.         <div class="validation_title">
  93.             <div class="pop_title">Validation</div>
  94.             <div class="close_image"><a href="#"class="close"/><img src="images/popups/close.jpg" border="0" /></a></div>
  95.         </div>
  96.         <div class="pop_content">
  97.             <div class="pop_message">Etiam vel nisl ante. Mauris congue sodales risus ac cele risque Etiam vel nisl ante.Etiam vel nisl ante.</div>
  98.             <div align="right"><input name="" type="button" value="Annuler" class="validation_bt"/> <input name="" type="button" value="OK" class="validation_bt"/></div>
  99.         </div>
  100.     </div>
  101. <!-- confirmation -->
  102.     <div id="confirmation" class="window" style="display:none;">
  103.         <div class="confirmation_title">
  104.             <div class="pop_title">Demande de Confirmation</div>
  105.             <div class="close_image"><a href="#"class="close"/><img src="images/popups/close.jpg" border="0" /></a></div>
  106.         </div>
  107.         <div class="pop_content">
  108.             <div class="pop_message">Etiam vel nisl ante. Mauris congue sodales risus ac cele risque Etiam vel nisl ante.Etiam vel nisl ante.</div>
  109.             <div align="right"><input name="" type="button" value="Exemple 1" class="confirmation_bt"/> <input name="" type="button" value="Exemple 2" class="confirmation_bt"/> <input name="" type="button" value="Exemple 3" class="confirmation_bt"/> <input name="" type="button" value="Annuler" class="confirmation_bt"/> <input name="" type="button" value="OK" class="confirmation_bt"/></div>
  110.         </div>
  111.     </div>
  112. <!-- Masque pour couvrir la page -->
  113.     <div id="mask"></div>
  114. </div>
  115.        
  116. string script = String.Format("afficherMessageInfo({0},{1})", id, messageInfo);
  117.        
  118. string script = String.Format("afficherMessageInfo('{0}','{1}')", id, messageInfo);
  119.        
  120. this.Page.ClientScript.RegisterStartupScript(this.GetType(),
  121. "afficherMessageInfo", script);
  122.        
  123. protected void Page_Load(object sender, EventArgs e)
  124. {
  125.     string id = "#info";
  126.     string messageInfo = "le dossier a été crée avec succès";
  127.  
  128.     BtnEnregistrer.OnClientClick = String.Format("afficherMessageInfo('{0}','{1}')", id, messageInfo);
  129.  
  130. }
  131.        
  132. // Round your values before using them since they can result in float.
  133. // Also you have to implicitly add '.px' to them.
  134.  
  135. //Get the screen height and width
  136. var maskHeight = $(document).height() + '.px';
  137. var maskWidth = $(window).width() + '.px';
  138.  
  139. //Set heigth and width to mask to fill up the whole screen
  140. $('#mask').css({
  141.     'width':maskWidth,
  142.     'height':maskHeight
  143. });
  144.  
  145. var windowH = Math.round(winH/2-$(id).height()/2) + '.px';
  146. var windowW = Math.round(winW/2-$(id).width()/2) + '.px';
  147.  
  148. $(id).css({
  149.     'top': windowH,
  150.     'left': windowW
  151. });