Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Public Class MyProfile
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Country.Text = Profile.Country
Gender.Text = Profile.Gender
Age.Text = Profile.Age.ToString
RoleList.DataSource = Roles.GetRolesForUser(User.Identity.Name)
RoleList.DataBind
End Sub
End Class
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class MyProfile : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e) {
Country.Text = Profile.Country;
Gender.Text = Profile.Gender;
Age.Text = Profile.Age.ToString();
RoleList.DataSource = Roles.GetRolesForUser(User.Identity.Name);
RoleList.DataBind();
}
}
Hi All,
I am lookingto do a profile page using vb.
I found the following example but its in c#...I have tried to convert it
but
with my limited knowledge
on c# I am struggling a bit. below
Is what I have tried which gives
me errors.
if anyone could help conver this code that would be great. Thanks
Here's a website you can use to convert c# to Vb or Vb to c#:
Code Converter.
And the result seems should be :
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Public Partial Class MyProfile
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Country.Text = Profile.Country
Gender.Text = Profile.Gender
Age.Text = Profile.Age.ToString()
RoleList.DataSource = Roles.GetRolesForUser(User.Identity.Name)
RoleList.DataBind()
End Sub
End Class
Strictly speaking it's unrelated to a language issue. RoleList is a control. VS should generate a MyPage.Designer.vb file with the proper control declarations.
Member
51 Points
179 Posts
cnvert c# to vb
Sep 13, 2019 08:22 AM|E.RU|LINK
Hi All,
I am lookingto do a profile page using vb.
I found the following example but its in c#...I have tried to convert it but with my limited knowledge on c# I am struggling a bit. below Is what I have tried which gives me errors. if anyone could help conver this code that would be great. Thanks
Contributor
3140 Points
983 Posts
Re: cnvert c# to vb
Sep 13, 2019 09:08 AM|Yang Shen|LINK
Hi E.RU,
Here's a website you can use to convert c# to Vb or Vb to c#: Code Converter.
And the result seems should be :
You are missing the double brackets for methods.
Hope this can help.
Best Regard,
Yang Shen
Member
51 Points
179 Posts
Re: cnvert c# to vb
Sep 13, 2019 09:11 AM|E.RU|LINK
thank you yang
however i still get errors on lines:
Country.Text = Profile.Country
Gender.Text = Profile.Gender
Age.Text = Profile.Age.ToString()
RoleList.DataSource = Roles.GetRolesForUser(User.Identity.Name)
RoleList.DataBind()
All-Star
48490 Points
18071 Posts
Re: cnvert c# to vb
Sep 13, 2019 09:24 AM|PatriceSc|LINK
Hi,
Strictly speaking it's unrelated to a language issue. RoleList is a control. VS should generate a MyPage.Designer.vb file with the proper control declarations.
Not sure about Profile. You had https://docs.microsoft.com/en-us/previous-versions/aspnet/2y3fs9xs(v=vs.100) but it's quite old now... The original C# sample doesn't give any explanation about that Profile ?
Edit: the modern approach would be rather to use https://docs.microsoft.com/en-us/aspnet/identity/overview/getting-started/introduction-to-aspnet-identity