Showing posts with label method. Show all posts
Showing posts with label method. Show all posts

Monday, March 26, 2012

newbie: Problem with CreateUserWizard

Hey

Below is the source code of the CreateUserWizard placed on one my web pages
(asp.net 2.0).

The problem is that the AssignUserToRole method isn't triggered when
clicking on the finish button (that Images/Go.gif image).

So I'm wondering what I'm doing wrong here

******************* markup ********************
<asp:CreateUserWizard FinishDestinationPageUrl="~/Default.aspx"
ID="CreateUserWizard1"
Width="300px" runat="server"
LoginCreatedUser="false"
CreateUserButtonType="Image"
CreateUserButtonImageUrl="Images/Go.gif"
OnFinishButtonClick="AssignUserToRole">

<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<label for="Username">User name:</label>
<asp:TextBox id="Username" runat="server" />

<label for="Password">Password:</label>
<asp:TextBox id="Password" runat="server"
TextMode="Password" />

<label for="ConfirmPassword">Confirm
Password:</label>
<asp:TextBox id="ConfirmPassword" runat="server"
TextMode="Password" />

<label for="Email">Email</label>
<asp:TextBox id="Email" runat="server" />

<label for="Question">Security question:</label>
<asp:TextBox id="Question" runat="server" />

<label for="Answer">Security answer:</label>
<asp:TextBox id="Answer" runat="server" />

</ContentTemplate>
</asp:CreateUserWizardStep>

<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
<ContentTemplate>rrrr</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>

***************** AssignUserToRole code **********************
protected void AssignUserToRole(object sender, EventArgs e)
{
MembershipUser user = Membership.GetUser();
user.IsApproved = false;
MailMessage mail = new MailMessage("name@dotnet.itags.org.somewhere.domain", user.Email,
"Thank you", "Hello World");
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(mail);
mail.Dispose();
}

Any suggestions?I put the functionality into the CreatedUser event

Jeff

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:e7LUO45SHHA.920@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Hey
>
Below is the source code of the CreateUserWizard placed on one my web
pages (asp.net 2.0).
>
The problem is that the AssignUserToRole method isn't triggered when
clicking on the finish button (that Images/Go.gif image).
>
So I'm wondering what I'm doing wrong here
>
******************* markup ********************
<asp:CreateUserWizard FinishDestinationPageUrl="~/Default.aspx"
ID="CreateUserWizard1"
Width="300px" runat="server"
LoginCreatedUser="false"
CreateUserButtonType="Image"
CreateUserButtonImageUrl="Images/Go.gif"
OnFinishButtonClick="AssignUserToRole">
>
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<label for="Username">User name:</label>
<asp:TextBox id="Username" runat="server" />
>
<label for="Password">Password:</label>
<asp:TextBox id="Password" runat="server"
TextMode="Password" />
>
<label for="ConfirmPassword">Confirm
Password:</label>
<asp:TextBox id="ConfirmPassword"
runat="server" TextMode="Password" />
>
<label for="Email">Email</label>
<asp:TextBox id="Email" runat="server" />
>
<label for="Question">Security
question:</label>
<asp:TextBox id="Question" runat="server" />
>
<label for="Answer">Security answer:</label>
<asp:TextBox id="Answer" runat="server" />
>
>
</ContentTemplate>
</asp:CreateUserWizardStep>
>
<asp:CompleteWizardStep ID="CompleteWizardStep1"
runat="server">
<ContentTemplate>rrrr</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
>
***************** AssignUserToRole code **********************
protected void AssignUserToRole(object sender, EventArgs e)
{
MembershipUser user = Membership.GetUser();
user.IsApproved = false;
MailMessage mail = new MailMessage("name@.somewhere.domain", user.Email,
"Thank you", "Hello World");
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(mail);
mail.Dispose();
}
>
Any suggestions?
>
>

newbie: problems with Profile.Providers

hey

asp.net 2.0

I want to search for 1 specific profile in my code. So I'm trying to use the
FindProfileByUserName method.
But before I use that method I must establish a provider object that can
call this method...

Here is part of my code:
String username = Request.QueryString["USERNAME"];
int totalProfiles;
SqlProfileProvider provider = (SqlProfileProvider)
Profile.Providers["SqlProvider"];
ProfileInfoCollection profiles =
provider.FindProfilesByUserName(ProfileAuthenticat ionOption.Authenticated,
username, 0, 1, out totalProfiles);

Much of this code is taken from the MSDN documentaion. my problem is that
this line don't work:
SqlProfileProvider provider = (SqlProfileProvider)
Profile.Providers["SqlProvider"];
The "provider" variable is still null after that line is executed, this
causes my code to crash... maybe it's a bad idea of my to specify provider
to be of the SqlProfileProvider class?

Here is my web.config file:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
</appSettings>
<connectionStrings>
<add name="aspnet_DB" connectionString="Data
Source=.\\SQLEXPRESS;Integrated
Security=True;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
Instance=true" />
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" />
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>

Any suggestions to what causes this?

jeffHey

I've found a work around to this problem so it isn't so urgent for me..

"Jeff" <it_consultant1@.hotmail.com.NOSPAMwrote in message
news:%23Lt0ZHvnGHA.964@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

hey
>
asp.net 2.0
>
I want to search for 1 specific profile in my code. So I'm trying to use
the FindProfileByUserName method.
But before I use that method I must establish a provider object that can
call this method...
>
Here is part of my code:
String username = Request.QueryString["USERNAME"];
int totalProfiles;
SqlProfileProvider provider = (SqlProfileProvider)
Profile.Providers["SqlProvider"];
ProfileInfoCollection profiles =
provider.FindProfilesByUserName(ProfileAuthenticat ionOption.Authenticated,
username, 0, 1, out totalProfiles);
>
Much of this code is taken from the MSDN documentaion. my problem is that
this line don't work:
SqlProfileProvider provider = (SqlProfileProvider)
Profile.Providers["SqlProvider"];
The "provider" variable is still null after that line is executed, this
causes my code to crash... maybe it's a bad idea of my to specify provider
to be of the SqlProfileProvider class?
>
Here is my web.config file:
<?xml version="1.0"?>
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
</appSettings>
<connectionStrings>
<add name="aspnet_DB" connectionString="Data
Source=.\\SQLEXPRESS;Integrated
Security=True;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
Instance=true" />
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" />
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>
>
>
Any suggestions to what causes this?
>
jeff
>

Saturday, March 24, 2012

Newbie: Questions about Cache object

Hi,
I'm trying to use Cache object for the first item. I've some questions
about that:
(1) Should Add, Remove and Insert method calls need to be synchronized ?
(2) Is it possible to add a cache dependency for cascading deletes i.e. if
cache key A is removed(based on time based expiration), so is key B which is
depnedent on it ?
Thanks in advance and regards
Navin1) If you want to be absolutely threadsafe using the Cache, use the Lock
keyword in your insert etc. methods.
2) Cascading deletes from the cache should be easy to implement using the
CacheItemRemovedCallback delegate , where in the callback target for item A
you would go ahead and remove Item B.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Navin Mishra" wrote:

> Hi,
> I'm trying to use Cache object for the first item. I've some questions
> about that:
> (1) Should Add, Remove and Insert method calls need to be synchronized ?
> (2) Is it possible to add a cache dependency for cascading deletes i.e. if
> cache key A is removed(based on time based expiration), so is key B which
is
> depnedent on it ?
> Thanks in advance and regards
> Navin
>
>
Thanks for quick response. For (2), is there any example ? In callback, how
I access the Cache object as it is part og request context ? Can a key item
dependency be used instead ?
Thanks again and regards
"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.nospammin.com> wrote in message
news:CA9F6ABA-FF0B-40EA-BAB2-D2077B90670C@.microsoft.com...
> 1) If you want to be absolutely threadsafe using the Cache, use the Lock
> keyword in your insert etc. methods.
> 2) Cascading deletes from the cache should be easy to implement using the
> CacheItemRemovedCallback delegate , where in the callback target for item
A
> you would go ahead and remove Item B.
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Navin Mishra" wrote:
>
if
which is

Newbie: Questions about Cache object

Hi,

I'm trying to use Cache object for the first item. I've some questions
about that:

(1) Should Add, Remove and Insert method calls need to be synchronized ?
(2) Is it possible to add a cache dependency for cascading deletes i.e. if
cache key A is removed(based on time based expiration), so is key B which is
depnedent on it ?

Thanks in advance and regards

Navin1) If you want to be absolutely threadsafe using the Cache, use the Lock
keyword in your insert etc. methods.

2) Cascading deletes from the cache should be easy to implement using the
CacheItemRemovedCallback delegate , where in the callback target for item A
you would go ahead and remove Item B.

Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com

"Navin Mishra" wrote:

> Hi,
> I'm trying to use Cache object for the first item. I've some questions
> about that:
> (1) Should Add, Remove and Insert method calls need to be synchronized ?
> (2) Is it possible to add a cache dependency for cascading deletes i.e. if
> cache key A is removed(based on time based expiration), so is key B which is
> depnedent on it ?
> Thanks in advance and regards
> Navin
>
Thanks for quick response. For (2), is there any example ? In callback, how
I access the Cache object as it is part og request context ? Can a key item
dependency be used instead ?

Thanks again and regards

"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.nospammin.com> wrote in message
news:CA9F6ABA-FF0B-40EA-BAB2-D2077B90670C@.microsoft.com...
> 1) If you want to be absolutely threadsafe using the Cache, use the Lock
> keyword in your insert etc. methods.
> 2) Cascading deletes from the cache should be easy to implement using the
> CacheItemRemovedCallback delegate , where in the callback target for item
A
> you would go ahead and remove Item B.
> Peter
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
> "Navin Mishra" wrote:
> > Hi,
> > I'm trying to use Cache object for the first item. I've some questions
> > about that:
> > (1) Should Add, Remove and Insert method calls need to be synchronized ?
> > (2) Is it possible to add a cache dependency for cascading deletes i.e.
if
> > cache key A is removed(based on time based expiration), so is key B
which is
> > depnedent on it ?
> > Thanks in advance and regards
> > Navin

Newbie: Static Method Instantiating Itself To Acess Non-static Propertys. Ok?

Hello,

I am newbie to the group so hi all! My name is Jim and I am a
codaholic. Ok so now that is out of the way.

I am new to using all things static and I am wondering if what I am
doing is going to get me in trouble.

I am using the component designer to build my Sql Server objects for
me. I then expose methods such as getDataSet as static methods. In
order to leverage the non-static properties that the designer creates
for me I instantiate a new object of the component designer and set its
properties accordingly (mainly the SqlServer connection on the command
objects so that each Sql server command has its own connection).

One thing of note:

1.) Private methods are exposed to the New Instance of the component
designer inside of the static method. (Makes me a bit concerned that
something funny is going on)

The code below gives an example.

using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Data.SqlClient;

namespace GoDAT.Venue
{

public class Venue : System.ComponentModel.Component
{
// ~~~~
// ~~~~
#region CONSTRUCTOR
public Venue(System.ComponentModel.IContainer container)
{
container.Add(this);
InitializeComponent();
}
public Venue()
{
InitializeComponent();
}
#endregion
// ~~~~
// ~~~~

// ~~~~
// ~~
#region DISPOSAL
protected override void Dispose( bool disposing )
{
//blah, blah, blah
}
#endregion

private System.Data.SqlClient.SqlCommand sqlSelect_Venue;
private System.Data.SqlClient.SqlCommand sqlInsert_Venue;
private System.Data.SqlClient.SqlCommand sqlUpdate_Venue;
private System.Data.SqlClient.SqlCommand sqlDelete_Venue;
private System.Data.SqlClient.SqlDataAdapter sqlDA_Venue;
private GoDAT.Venue.dsVenue dsVenue1;
// ~~~~~
// ~~~~~

// ~~~~
// ~~~~
#region Component Designer generated code
// ALL THAT GREAT CODE GENERATED FOR FREE!!!!
// Or rather for the price of VS.NET and the
// hours of trial and error trying to figure
// out how to best leverage it.
#endregion
// ~~~~
// ~~~~

// ~~~~
public static GoDAT.Venue.dsVenue Get_dsVenue()
{

Venue tmpThis = new Venue();
GoDAT.Venue.dsVenue tmpDS = tmpThis.dsVenue1;
SqlDataAdapter adapter = tmpThis.sqlDA_Venue;

tmpThis.sqlSelect_Venue.Connection = SQLConnMgr.GetSqlConn();
tmpThis.sqlSelect_Venue.Connection.Open();
try
{
adapter.Fill(tmpDS);
}
catch (Exception e)
{
System.Diagnostics.Trace.WriteLine(("[Get_dsVenue] Exception " +
e.Message));
}
finally
{
adapter.Dispose();
tmpThis.sqlSelect_Venue.Connection.Close();
tmpThis.sqlSelect_Venue.Connection = null;
tmpThis = null;
}

return tmpDS;
}
// ~~~~~
}
}"Electric Co." <jmcphee@.ucalgary.cawrote in message
news:1155145846.449750.188470@.m79g2000cwm.googlegr oups.com...

What you did seems to be ok, however I would create a private static field
to your class and create your Venue object there. E.g

private static Venue venue = new Venue();

Then this variable could be access by all other methods in this class and
you only have to create this object once. Also, if you want to prevent this
class from begin created by some client code you could also make your
constructor private.

HTH

Quote:

Originally Posted by

Hello,
>
I am newbie to the group so hi all! My name is Jim and I am a
codaholic. Ok so now that is out of the way.
>
>
I am new to using all things static and I am wondering if what I am
doing is going to get me in trouble.
>
I am using the component designer to build my Sql Server objects for
me. I then expose methods such as getDataSet as static methods. In
order to leverage the non-static properties that the designer creates
for me I instantiate a new object of the component designer and set its
properties accordingly (mainly the SqlServer connection on the command
objects so that each Sql server command has its own connection).
>
One thing of note:
>
1.) Private methods are exposed to the New Instance of the component
designer inside of the static method. (Makes me a bit concerned that
something funny is going on)
>
The code below gives an example.
>
>
>
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Data.SqlClient;
>
namespace GoDAT.Venue
{
>
public class Venue : System.ComponentModel.Component
{
// ~~~~
// ~~~~
#region CONSTRUCTOR
public Venue(System.ComponentModel.IContainer container)
{
container.Add(this);
InitializeComponent();
}
public Venue()
{
InitializeComponent();
}
#endregion
// ~~~~
// ~~~~
>
// ~~~~
// ~~
#region DISPOSAL
protected override void Dispose( bool disposing )
{
//blah, blah, blah
}
#endregion
>
private System.Data.SqlClient.SqlCommand sqlSelect_Venue;
private System.Data.SqlClient.SqlCommand sqlInsert_Venue;
private System.Data.SqlClient.SqlCommand sqlUpdate_Venue;
private System.Data.SqlClient.SqlCommand sqlDelete_Venue;
private System.Data.SqlClient.SqlDataAdapter sqlDA_Venue;
private GoDAT.Venue.dsVenue dsVenue1;
// ~~~~~
// ~~~~~
>
// ~~~~
// ~~~~
#region Component Designer generated code
// ALL THAT GREAT CODE GENERATED FOR FREE!!!!
// Or rather for the price of VS.NET and the
// hours of trial and error trying to figure
// out how to best leverage it.
#endregion
// ~~~~
// ~~~~
>
// ~~~~
public static GoDAT.Venue.dsVenue Get_dsVenue()
{
>
Venue tmpThis = new Venue();
GoDAT.Venue.dsVenue tmpDS = tmpThis.dsVenue1;
SqlDataAdapter adapter = tmpThis.sqlDA_Venue;
>
tmpThis.sqlSelect_Venue.Connection = SQLConnMgr.GetSqlConn();
tmpThis.sqlSelect_Venue.Connection.Open();
try
{
adapter.Fill(tmpDS);
}
catch (Exception e)
{
System.Diagnostics.Trace.WriteLine(("[Get_dsVenue] Exception " +
e.Message));
}
finally
{
adapter.Dispose();
tmpThis.sqlSelect_Venue.Connection.Close();
tmpThis.sqlSelect_Venue.Connection = null;
tmpThis = null;
}
>
return tmpDS;
}
// ~~~~~
}
}
>


"Electric Co." <jmcphee@.ucalgary.cawrote in message
news:1155145846.449750.188470@.m79g2000cwm.googlegr oups.com...
You don't have to do what I suggested, you may been to weigh the pro's and
con's first before you do.

Quote:

Originally Posted by

Hello,
>
I am newbie to the group so hi all! My name is Jim and I am a
codaholic. Ok so now that is out of the way.
>
>
I am new to using all things static and I am wondering if what I am
doing is going to get me in trouble.
>
I am using the component designer to build my Sql Server objects for
me. I then expose methods such as getDataSet as static methods. In
order to leverage the non-static properties that the designer creates
for me I instantiate a new object of the component designer and set its
properties accordingly (mainly the SqlServer connection on the command
objects so that each Sql server command has its own connection).
>
One thing of note:
>
1.) Private methods are exposed to the New Instance of the component
designer inside of the static method. (Makes me a bit concerned that
something funny is going on)
>
The code below gives an example.
>
>
>
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Data.SqlClient;
>
namespace GoDAT.Venue
{
>
public class Venue : System.ComponentModel.Component
{
// ~~~~
// ~~~~
#region CONSTRUCTOR
public Venue(System.ComponentModel.IContainer container)
{
container.Add(this);
InitializeComponent();
}
public Venue()
{
InitializeComponent();
}
#endregion
// ~~~~
// ~~~~
>
// ~~~~
// ~~
#region DISPOSAL
protected override void Dispose( bool disposing )
{
//blah, blah, blah
}
#endregion
>
private System.Data.SqlClient.SqlCommand sqlSelect_Venue;
private System.Data.SqlClient.SqlCommand sqlInsert_Venue;
private System.Data.SqlClient.SqlCommand sqlUpdate_Venue;
private System.Data.SqlClient.SqlCommand sqlDelete_Venue;
private System.Data.SqlClient.SqlDataAdapter sqlDA_Venue;
private GoDAT.Venue.dsVenue dsVenue1;
// ~~~~~
// ~~~~~
>
// ~~~~
// ~~~~
#region Component Designer generated code
// ALL THAT GREAT CODE GENERATED FOR FREE!!!!
// Or rather for the price of VS.NET and the
// hours of trial and error trying to figure
// out how to best leverage it.
#endregion
// ~~~~
// ~~~~
>
// ~~~~
public static GoDAT.Venue.dsVenue Get_dsVenue()
{
>
Venue tmpThis = new Venue();
GoDAT.Venue.dsVenue tmpDS = tmpThis.dsVenue1;
SqlDataAdapter adapter = tmpThis.sqlDA_Venue;
>
tmpThis.sqlSelect_Venue.Connection = SQLConnMgr.GetSqlConn();
tmpThis.sqlSelect_Venue.Connection.Open();
try
{
adapter.Fill(tmpDS);
}
catch (Exception e)
{
System.Diagnostics.Trace.WriteLine(("[Get_dsVenue] Exception " +
e.Message));
}
finally
{
adapter.Dispose();
tmpThis.sqlSelect_Venue.Connection.Close();
tmpThis.sqlSelect_Venue.Connection = null;
tmpThis = null;
}
>
return tmpDS;
}
// ~~~~~
}
}
>


Hi,

Thanx, I thought your suggestion was brilliant.

Jim