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

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 0.66 KB  |  hits: 20  |  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. Passing a JavaScript variable in SQL Datasource in ASP.Net C#
  2. var div = document.getElementById('main_content').offsetHeight;
  3.             var length = Mah.round(div / 400);
  4.        
  5. <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:qbuyConnectionString1 %>"
  6.          SelectCommand="SELECT TOP variable * FROM [advertisement] WHERE ([enable] = @enable) ORDER BY NEWID()">
  7.         <SelectParameters><asp:Parameter DefaultValue="1" Name="enable" Type="Int32" /></SelectParameters>
  8. </asp:SqlDataSource>
  9.        
  10. $.get('query.asp', {length: length});
  11.        
  12. <input type="hidden" id="dataForSQL"></input>
  13.        
  14. $('#dataForSQL').html(length);