ASP.net membership

Capodecina
Permabanned
Joined
31 Dec 2003
Posts
5,172
Location
Barrow-In-Furness
I've had a scan around and I can't seem to find much information. It's all well and good running the aspnet_regsql.exe to setup the database locally, but i'm working on a remote database and this can not change.

How can I configure this database so I can use the built-in membership controls?

Creating a custom one myself is for the time being not really plausable because i've onloy just started learning ASP.

It was suggested to me that I run the aspnet_regsql.exe locally and then copy the SQL code and execute it to remotely generate the tables etc? Is there anywhere I can find the SQL code for the aspnet_regsql.exe? I can't have an SQL server running on a local machine so I need another way to get it/do this.

It needs to work with the built-in ASP.net membership controls.

Grr :(
 
I can't believe I didn't try putting in the server name before asking :o

Hold this space, i'll no doubt return shortly with a question.

Kevin I love you by the way.
 
How can I get a page to refresh when i've inserted data using a detailsview?

I have a GridView that needs to update on the same page with the information that has just been inserted, if you understand what I mean?

I've looked about for an autopostback but can't find it. I am solely using the detailsview for inserting here, no editing or displaying etc.
 
When i try administer the website and test the provider it says it can not establish a connection to the database.

The only provider I can test is "AspNetSqlProvider".
 
Here's what I have in my web.config file:

Code:
<connectionStrings>
  <add name="TrainingConnectionString" connectionString="Data Source=GLKAS0312;Initial Catalog=Training;Persist Security Info=True;User ID=****;Password=****"
   providerName="System.Data.SqlClient" />
 </connectionStrings>

<membership defaultProvider="MyMembershipProvider">
      <providers >
        <clear/>
        <add connectionStringName="TrainingConnectionString"
         name="MyMembershipProvider" type="System.Web.Security.SqlMembershipProvider"/>
      </providers>
    </membership>

With the membership part added there is now no providers under the provider list when I try administer it.

:(
 
Cheers :)

The thing is, I still haven't really worked out how to display data how I originally intended for this application. That could be a problem...
 
As I was going through the security wizard setup, I got a little way in then received this error:

An error was encountered. Please return to the previous page and try again.

The following message may help in diagnosing the problem: Unable to connect to SQL Server database. at System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean isMembership, String methodName, Object[] parameters, Type[] paramTypes) at ASP.security_wizard_wizardpermission_ascx.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I got this just after I had selected I wished to use Roles.
 
Last edited:
I've got the membership working now, but I really need to find some guide or tutorial on how to actually obtain UserIDs and input them into the database. Using sessions or whatever, i'm new to all this and I can't find a thing.

Can't seem to find any tutorials on it anywhere :(
 
I'm trying to learn and work out to how I have different users input data input the system and have their userid stored along with the data.

At the moment I have just created the design on the website and created a version which works but without different users.

Now the membership is working I need to update the rest of the application to suit this.

Is that any clearer?
 
I've really not explained this welllll ha-ha.

Can you remmeber what i'm trying to create?

It's basically an application which will allow users to log the ammount of time they have spent on a task.

At the moment it works without using users, so no userid is stored, just a unique ID of the record and then the rest of the information.

I've not got the ASP.net membership setup so I need to now change the application so that it works using users.
 
The SQL Database is being a pain in the bum!

Wont let me make a relationship to the UserName table, the fields are exactly the same type and I tried deleting all data first too. Grrr!

I can't seem to workout how I can use LoginName to get the UserName into the textbox? I'm guessing something like:

TextBox1.Text = LoginName1

I don't know where this code goes though, because if I put it on page load it says TextBox1 is not declared, and LoginName too.

ARGHHHHHHHH

lol
 
I think that's the problem, the textbox I need to take in the UserName is inside a InsertItem template of a DetailsView.
 
Last edited:
Using the code under the TextChanged event:

Code:
  Dim myTextBox As New TextBox

        myTextBox = CType(DetailsView1.FindControl("UserNameBox"), TextBox)

        If myTextBox.Text = "=" Then
            myTextBox.Text = Me.LoginName1.ToString()
        End If

It's saying LoginName1 is not a member of the page, is it because it hasn't been declared as a variable and wont work for the same reason as the textbox?

What does CType do, i've seen it a few times but it has never been explained.

You'v helped me more than most of the stuff i've read dude <3
 
Last edited:
The LoginName label is sat next to the TextBox in the InsertItemTemplate at the moment, as i'm writing this i've probably realised that is the very problem....
 
Ok I sorted that, but when I press = is just puts "System.Web.UI.WebControls.LoginName" into the TextBox.

I really need it to do it without putting = though, so would sticking it on a page load event work?

Saying that I could just put it as "" for any of the fields that require text. I'll probably hide the field once it's properly working anyways, no need for the user to see it.
 
I don't think it will work in the page_load event, as the TextBox and LoginName
only get created when the DetailsView changes to the insert mode.

What you could do is instead of putting it under the TextChanged event, add it to the DataBinding event.

Get rid of the If statement, and to get the name you need to use the following:

Code:
myTextBox.Text = myLoginName.Page.User.Identity.Name

My bad :o

Cheers for that, i'll give it a go!

The DetailsView default mode is insert, if that makes any difference. On this paticular page it is being used solely for inserting data.
 
Last edited:
If I use:

Code:
Dim myTextBox As New TextBox

        myTextBox = CType(DetailsView1.FindControl("UserNameBox"), TextBox)

        myTextBox.Text = "=" Then
        myTextBox.Text = UserNameBox.Page.User.Identity.Name

It says UserNameBox is not declared, same if I use myLoginName
 
Back
Top Bottom