Thursday 15 September 2011

c# - Passing session or cookie variables to server tags in ASP.NET -



c# - Passing session or cookie variables to server tags in ASP.NET -

this simple question but, eludes me, have variable have set code-behind session in page of asp.net application. let's is: session["username"] , want pass code behind page server tag. server tag looks this:

<asp:sqldatasource id="sqldatasourcedelta" runat="server" connectionstring="<%$ connectionstrings:connectionstringalpha %>" selectcommand="select [thingtitle], [thingsynopsis], [thingcategory], [thingtype], [thingusername] [thingofsubmissions] thingusername = <%$ session["username"] %>"

i can't use: <%$ session["username"] %> straight in server tag shown above without generating error mal formed server tags. question is, how can pass session variable or other application variable (non sql server variable) bit of code?

you set property in server-side code ?

sqldatasourcedelta.selectcommand = string.format("select [thingtitle], [thingsynopsis], [thingcategory], [thingtype], [thingusername] [thingofsubmissions] thingusername = '{0}'", session["username"]);

c# asp.net session c#-4.0 cookies

No comments:

Post a Comment