Apr 19 2007

Telerik C#/VB.NET Converter

Category: Telerik ControlsBil@l @ 06:18

I would like to inform you about the Telerik Code Converter from C# --> VB.NET and VB.NET --> C#.

The converted code looks great, nicely formatted, saving the original format and spacing!!

Great work Telerik! Thanks!!!

You can check the converter at: http://converter.telerik.com/

HTH,
Regards

Tags:

Apr 4 2007

RegisterHiddenField and ID property

Category: ASP.NET 2.0 - GeneralBil@l @ 10:43

In a previous post I talked about the xListBox and MoverList Controls. I did some fixes to make them work for FireFox and IE.

What was the problem actually? If you read the article about xListBox, you will notice that I have based on solution on a HiddenField to keep track of added/removed items from the ListBox on the client side and to reflect the changes on the server side.

The problem was that, RegisterHiddenField in ASP.NET 1.1, was not generating an ID for the hidden field on the HTML and I was using the document.getElementById, FireFox was having a problem in this, while IE as usual has no problem with anything [:D].

I could have used document.getElementByName, but I prefered to use the one by ID. So what I did is that, I had to customize the way the RegisterHiddenField works. The idea I got from this post: ASP.NET's RegisterHiddenField and document.getElementById

However, I had to modify it a bit to look something as:

    string hiddenFieldName = this.ClientID + "_REMOVED";
    if (!HttpContext.Current.Request.Browser.ToString().Equals("IE"))
        hiddenFieldName =  hiddenFieldName + "\"" + " id=\"" + hiddenFieldName;

This way, I did a trick to add the name of the HiddenField and an ID for the HiddenField and that worked perfect!!

Maybe you can use this trick in your work somewhere!

Hope this helps,
Regards

Tags:

Apr 4 2007

Expression Products Added to MSDN

Category:Bil@l @ 06:57

Expression Products are part of the MSDN downloads. Check this post by Scott Guthrie:

Expression Products Added to MSDN

That is really cool!!

Regards

Tags:

Apr 4 2007

xListbox and Mover-Control

Category:Bil@l @ 06:36

In my previous articles that I have written on ASPAlliance.com under the titles of:

I have developed an extended ListBox that preserves changes on the client-side and after a call to server-side too. Sometimes you might need to add items to a ListBox on the client-side and need to preserve the changes after a postback. Well, this is not the behavior of the ListBox that ships with ASP.NET x.x.

In the above articles, I added this functionality such that, ListBox can now preserve the changes on the client-side. In the other article article, I used the xListBox to create a Mover-Control. Two xListboxes facing each other where you can move items from one Listbox to another and preserve the changes on the client and server sides.

However, both controls were not working on browsers other than IE! I had to fix them and now they work well on:

IE (5.5+), FireFox (2.0), and Opera (9.10)

You can download the xListBox here: https://bhaidar.net/cs/files/folders/april_2007/entry2425.aspx

You can download the Mover-Control here: https://bhaidar.net/cs/files/folders/april_2007/entry2426.aspx

Both downloads include the ".cs" and ".dll".

If you still have any problem or question feel free to contact me and I will do my best to make my controls look better!

Regards

Tags:

Apr 2 2007

Enable Fiddler on FireFox

Category:Bil@l @ 16:08

I was trying to debug an ASPX page today on FireFox to see what was going on. I usually use Fiddler to do this especially when I want to know what is being send/received. I wanted to debug on FireFox however, I noticed that Fiddler doesn't work on Firefox without some configuration settings.

Please check this URL to see how to enable Fiddler on FireFox:
http://nil.checksite.co.uk/index.cfm/2006/4/12/Using-Fiddler-with-Firefox

 

Hope this helps,
Regards

Tags:

Apr 1 2007

PasswordRecovery in ASP.NET 2.0 Membership API

Category:Bil@l @ 14:10

I have been lately developing a small website where I used the ASP.NET 2.0 Membership API to manage my users, create new users, etc ...

I decided however, not to use any of the built-in controls present on the VS 2005 toolbox to create new users, login, etc ... But, I made use of the Membership API instead. So everything was done programmatically using the Membership API to create new user, password recovery, login, etc ...

One thing I noticed that the Membership API has so many methods that come handy in such a solution except a PasswordRecovery method. There is GetPassword() method, however, so many other checking need to be done for example, does the current Membership Provider allow Password Retreival? Do retreiving a password requires a Question/Answer?

I found myself writing a small utility method that does all this checking and can be added to the Membership API methods to help you create a user management system programmtically, where alll functionalities are present!

Have a look at the code with the comments inside.

        /// <summary>
        /// Recovers a password given the username, secret question/answer.
        /// It can be used to recover password programmatically
        /// </summary>
        /// <param name="userName">UserName to which to recover the password</param>
        /// <param name="answer">The Secret Answer</param>
        /// <param name="status">Holds any messages of failure</param>
        /// <returns>Password to be recovered</returns>
        public static string PasswordRecovery(string userName, string answer, out string status)
        {
            // Initialize the status
            status = "";
            string pwd = "";

            // If the current provider configuration does not
            // allow password retrieval, go back
            if (!Membership.EnablePasswordRetrieval) {
                status = "Current Membership provider configuration doesn't allow password retrieval";
                return "";
            }

            // Check if the current provider requires question/answer
            // and check if the corresponding inputs are ok
            if (Membership.RequiresQuestionAndAnswer)
            {
                if (string.IsNullOrEmpty(answer)) {
                        status = "Secret answer is missing";
                    }

                if (status != "")
                    return "";
            }               

            // Validate the input
            if (string.IsNullOrEmpty(userName)) {
                status = "UserName is empty or null";
                return "";
            }

            // Get the user with the above username
            MembershipUser user = Membership.GetUser(userName);
            if (user == null)
            {
                status = "UserName doesn't exist in the database";
                return "";
            }
            else {
                // If provider is configured to use Secret question/answer
                // use the overloaded version of the GetPassword to pass in
                // the secret answer
                if (Membership.RequiresQuestionAndAnswer)
                {
                    try
                    {
                        pwd = user.GetPassword(answer);
                    }
                    // If answer is wrong, usually a MembershipPasswordException
                    // is usually thrown.
                    catch (MembershipPasswordException ex)
                    {
                        status = "Secret answer is wrong";
                        return "";
                    }
                }
                else {
                    // Retrieve the password without the secret answer
                    pwd = user.GetPassword();
                }

                // Password is OK
                status = "";
                return pwd;
            }
        }

Hope this code helps!
Regards

Tags:

Apr 1 2007

Once again a Visual Developer ASP/ASP.NET MVP

Category:Bil@l @ 09:58

I have been awarded the Visual Studio - ASP/ASP.NET Award for the 3rd consecutive year!

Hope this year will be a fruitful year too in helping the community in growing up, sharing more and more knowledge with the personal hope of ASPing the whole world [;)].

 

Regards

Tags: