Trying to convert from C# to VB.net -
i trying change c# code vb.net , running issue username select box not populating list of membership users. c# code displays users list.
c#
using system; using system.collections.generic; using system.linq; using system.web; using system.web.security; using system.web.ui; using system.web.ui.webcontrols; public partial class admin_change_change : system.web.ui.page { membershipusercollection users; protected void page_loadcomplete(object sender, eventargs e) { users = membership.getallusers(); if (!ispostback) { username.datasource = users; username.databind(); } } protected void btnchange_click(object sender, eventargs e) { membershipuser usertochange = membership.getuser(username.selecteditem.value); if (usertochange != null) { usertochange.changepassword(usertochange.resetpassword(), newpassword.text); response.redirect("/admin/"); } else { message.text = "invalid username or password"; } } protected void btngoback_click(object sender, eventargs e) { response.redirect("/admin/"); } }
vb.net
imports system.collections.generic imports system.linq imports system.web imports system.web.security imports system.web.ui imports system.web.ui.webcontrols public partial class admin_change_change inherits system.web.ui.page private users membershipusercollection protected sub page_loadcomplete(sender object, e eventargs) users = membership.getallusers() if not ispostback username.datasource = users username.databind() end if end sub protected sub btnchange_click(sender object, e eventargs) dim usertochange membershipuser = membership.getuser(username.selecteditem.value) if usertochange isnot nothing usertochange.changepassword(usertochange.resetpassword(), newpassword.text) response.redirect("/admin/") else message.text = "invalid username or password" end if end sub protected sub btngoback_click(sender object, e eventargs) response.redirect("/admin/") end sub end class
your event handler missing handles me.loadcomplete
@ end of it:
protected sub page_loadcomplete(sender object, e eventargs) handles me.loadcomplete users = membership.getallusers() if not ispostback username.datasource = users username.databind() end if end sub
Comments
Post a Comment