Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

asp.net - Using the username or Page.User.Identity.Name for select parameter -


i have login control inside loginview control , on loggedin template, there gridview , sqldatasource.

what need use username filter gridview. error object reference not set instance of object.. tried adding .tostring page.user.identity.name

take @ code below:

<asp:loginview id="loginview1" runat="server"> <anonymoustemplate>     <asp:login id="login1" runat="server"  onloggedin="login1_loggedin">             </asp:login> </anonymoustemplate>  <asp:sqldatasource id="sqldatasource1" runat="server"     connectionstring="<%$ connectionstrings:applicationservices %>"     providername="<%$ connectionstrings:applicationservices.providername %>"     selectcommand="select distinct [username], [date], [timein], [timeout], [total] [attendance] order [date] username = @username ">     <selectparameters>         <asp:parameter name="username" />     </selectparameters>             </asp:sqldatasource> 

for code-behind

protected sub login1_loggedin(byval sender object, byval e eventargs)      trycast(loginview1.findcontrol("sqldatasource1"), sqldatasource).selectparameters("username").defaultvalue = page.user.identity.name  end sub 

page.user.identity.name not set until page re-loaded. not available in loggedin event instead can use login1.username. since hit loggedin event confirmed credentials valid. in case since login control inside of loginview control, have first reference control below:

protected sub login1_loggedin(byval sender object, byval e eventargs)       dim login1 login = directcast(sender, login)     trycast(loginview1.findcontrol("sqldatasource1"), sqldatasource).selectparameters("username").defaultvalue = login1.username  end sub 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -