How to add password field in Grid View in c# - c#

I want to create password field in Data Grid view in WinForm c# .NET.
How should i proceed?

If it's for creating a password and you must do it in the grid, just use plain text and clear it out once you create the account.
If you're building an app where a customer service rep builds an account for a user, either send the user a password you generate or use some default password for your company (I would only use this with internal-use-only software). Then force them to change it on the user's first login.
I can only assume you don't want the ability of your grid users to view passwords. If indeed that is the case, don't do it!!!

Try the following code. It may helpful to you.
protected void GridView1_PreRender1(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
string pwd = new string('*', row.Cells[2].Text.Length);
}
}

Related

C# ASP.NET Identity

I have a scenario here whereby when a user wants to reset a password, the system will have to send a temporary random generated password to the user by email. I tried storing the temporary password into a new column in the database but I am not really sure about whether this approach works well. Some people recommend using token such as below:
string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
However, I am really new to ASP.NET and I am not familiar with token. How do I compare the temporary generated token with the token in the database?
Another method that I found to implement this is to have a Membership.GeneratePassword function that generates a random string of characters:
model.temppwd = Membership.GeneratePassword(10, 1);
Can anybody provide me an ideal way to implement this functionality with some example? Thank you!
In our project we used
Guid.NewGuid();
and sent the email containing the link to the recover password action (MVC) as a query string: https://yoursite.com/account/reset/?code=your_guid_code
Example:
ResetPassword resetPassword = new resetPassword();
resetPassword.Code = Guid.NewGuid();
string strLink = string.Format("{0}", actionUrl + "?code="+ resetPassword.Code);`
And now you can use the strLink to send with your e-mail. You'll need to store the Guid in a database table alongside with the userId, so that you can implement the resetting procedure. When the user clicks the link from your email he'll get in a form / view that asks for a new password. Also you'll want to add an extra column to that table in order to provide an expiration limit for that code. If the user clicks the link in the e-mail and the code expired you'll have to inform the user and send another e-mail with another code.

Recognize user already logged in C# WPF

I have created the registration and login form. Both work perfectly. But how do i recognize the user logged in as the PHP does by using SESSIONS and COOKIES. I can use static class to get data between different pages, but how can i retrieve the logged user data if he closes the application.
Is there any way for achieving this?
Thanks!
I'm assuming that you want something like instant messenger applications like Skype, or cloud storage applications like DropBox, OneDrive or Mega do. They ask you to enter user name and password once, and then start automatically without asking for user's credentials again.
They achieve this by storing user name and password in encrypted format in the file they normally keep in application folder under specific user account. See the following link for details: How can I get the current user directory?
This is standard practice, as another user will not be automatically logged into your app, if they not entered their own credentials.
Make sure you encrypt the user name and password or the whole file before saving it to disk, otherwise it may become an easy target for password stealing malware.
You should use user settings to do this, as this mechanism hides all the necessary work for creating files in the right locations, etc. from the developer. It works fine and it is made for stuff like this.
You design them in Visual Studio in the project properties on the "Settings" tab. Make sure to select the settings type correctly, as application settings are read-only.
Assume you have to settings UserName and UserPassword. Then, in your code, you could do this:
if (String.IsNullOrWhitespace(Properties.Settings.Default.UserName))
{
// USER NEEDS TO LOG IN
string userName;
string password;
if (Login(out userName, out password))
{
try
{
Properties.Settings.Default.UserName = Encrypt(userName);
Properties.Settings.Default.Password = Encrypt(password);
Properties.Settings.Default.Save();
}
catch (Exception exp)
{
...
}
}
}
else
{
// USER IS ALREADY LOGGED IN
}
private bool Login(out string userName, out string password) would be a method that shows a login user interface and returns true on success or false on failure.
private string Encrypt(string input) would be a method to encrypt a string.

Create a Link to a Paypal setting the email address static

I have been researching up creating my own link to PayPal, that when a person is logged in, it will generate a "specified email" in the "To:" text box on the form.
However, I am planning something a tad more ambitious; I'd like to know it is possible to build this link in my code to where the specified email "cannot be edited or changed?" Again, this would coming from my custom-made link:
https://www.paypal.com/us/cgi-bin/webscr?cmd=_send-money&nav=1&email=SomePresetEmail#mail.com
How can I code this to set "SomePresetEmail#mail.com" to be static? Or is that even possible for me to do that, being I am not editing the code on Paypal's server side? My site is currently built using Asp.Net WebForms.
DesignerMind,
I am not sure if I am following you correctly. But this link is displayed on the page to user and you want them to not be able to change the email?
Is it possible to have your link point to an address inside your application that gets redirected to Paypal? When paypal recieves the request, they execute an internal mechanism to hash the request into a secured request variable. This means that when you navigate to the link the user is not seeing the actual link but a hashed version. A sample of the paypal hashed version is.
https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=Itqgb8iQ3mW92FT9ldzgcFmJyRVQLUpE2u9UMqeKbGmvwdMTY80oBEmo0SS&dispatch=5885d80a13c0db1f8e263663d3faee8def8934b92a630e40b7fef61ab7e9fe63
Now you could try to do this such as.
On your aspx.net page.
<asp:HyperLink runat="server" ID="paypalLink" NavigateUrl="~/Paypal.aspx" />
or simply
Paypal
And in the Paypal.Aspx code
static string SecretEmail = "someone#somewhere.com",
PaypalRedirectFormat = "https://www.paypal.com/us/cgi-bin/webscr?cmd=_send-money&nav=1&email={0}";
protected void Page_Load(object sender, EventArgs e)
{
Response.Redirect(string.Format(PaypalRedirectFormat, SecretEmail));
}
This is just an idea and actually if this is what you wanted a GenericHandler would do the job quite nicely.
Let me know if this is not what you are looking for.

How to get userID from login on webbrowser c# for windows phone?

I am trying to retrieve the UserID that is returned once I have entered and submitted correct username and password.
I have been struggling to:
Close the Web-browser once it has successfully logged in. (it just redirects to a page with the UserID and has URL with user id in the end.
Retrieve the UserID once logged in.
I have tried this to retrieve the user id with no success.
OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs ex)
{
base.OnNavigatedTo(ex);
IDictionary<string, string> parameters = NavigationContext.QueryString; //once the login is successful this piece of code should be
if (parameters.ContainsKey("id")) //executed
{
string UserId = parameters["id"];
}
}
I have then tried the below. I get the current URL and not the loaded one. As well as that how can I parse it to just get the user id?
private void webBrowser2_Navigated(object sender, NavigationEventArgs e)
{
string URLString = e.Uri.ToString();
txtURL.Text = URLString;
I think I am probably just having problems with the event handler and parsing.
Sorry, I am new to this so please forgive any mistakes I have made.
Thanks.
The Navigated event will fire each time a new page is loaded in the control. So the event will be fired first when your login page is navigated to, you would ignore this. The next time the event will fire as a result of navigation in the control and this time will either be from the user successfully logging in or a failure. Either way you'll need to read the Uri and parse out the relevant parameters. You can extract just the query elements from the uri using the Query property. See here for details http://msdn.microsoft.com/en-us/library/system.uri.query(v=vs.95).aspx

How to validate Multiple Ids in the Webservice Method

hai Friends
I am using this coding for validating the emailID online through webservice method.i will get a input a from a textboa and the click the button.but it is validating the emailId only one at a time.how to vaildate multiple EmaiIDs and validate and return the values.or how to split the ids and validate let me know.
The webservice link is http://www.webservicex.net/ValidateEmail.asmx?wsdl
So far my coding is
protected void ValidateEmail_Click(object sender, EventArgs e)
{
ValidateEmail.ValidateEmailSoapClient EmailClient = new ValidateEmail.ValidateEmailSoapClient("ValidateEmailSoap12");
bool bval = System.Convert.ToBoolean(EmailClient.IsValidEmail(txtvalidateEmail.Text));
Response.Write("Email Address is " + bval.ToString());
}
The link you've posted doesn't open here but I will try to answer your question. If the web service has another method that allows you to pass multiple email addresses then you can use this method. If not, you will need to call the web service for each email you are trying to validate which of course might not be very efficient.

Categories

Resources