ASP.Net Navigation/Validation STRANGE PROBLEM

Last post 03-18-2007 7:54 AM by Dhuka. 8 replies.

Sort Posts:

  • ASP.Net Navigation/Validation STRANGE PROBLEM

    03-16-2007, 5:49 AM
    • Loading...
    • Dhuka
    • Joined on 03-15-2007, 8:52 AM
    • Posts 110

    Heloo everybody

    I am having a problem in a web application that i am developing. My web application comprises of several form each having a few buttons at the top of the form e.g ADD, EDIT, SAVE, CANCEL etc. for form operations. I also have a textbox on my form in which user may type RECODE_ID directly and press ENTER to fetch information about that record. Pressing enter causes a post back to the server where in PAGE_LOAD event has been coded as below:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Not Page.IsPostBack Then

               Call InitializePageControls()

               Call SwitchDisplayMode(FORM_MODE.FM_INQUIRE) '''''''''''''''''' sets relevant fields + button enabled or disabled

               Call SetPermissions() ''''''''''''sets form permission for the user based on his/her rights

    Else

              If Request.Form("__EVENTTARGET") = "RECORD_ID" Then

                        LoadRECORD( Request.Form("__EVENTARGUMENT") )

              End If

    End If

    End Sub

    Now the problem is that when I enter the RECOR_ID and press ENTER a post back to the server happens which loads RECORD DATA but right after loading the record my ADD BUTTONS click event btnAdd_Click() is also gets called which i don't want as pressing ADD button cause screen control values to re-initialize and hence all the data that was loaded disappears.

    NOTE: Upon closer observation I realized that whenever my textbox txtRecordID is in focus, a box is also visible around ADD BUTTON. Moreover, if I generate a post back through a way that doesn't require me to press ENTER in txtRecordID, it works fine.

    Can any body suggest me what should I do to prevent ADD BUTTON CLICK event from invoking upon ENTER PRESS in txtRecordID.

    Regards,

    Zulfiqar Dhuka 

     

  • Re: ASP.Net Navigation/Validation STRANGE PROBLEM

    03-16-2007, 9:30 AM
    • Loading...
    • imran.nathani
    • Joined on 04-07-2006, 9:32 AM
    • Toronto,Canada
    • Posts 836

    on the client side for the textbox restrict the keystrokes for  txtRecordID by javascript.use the following code on the keydown event of txtRecordID.

     

    function RC(e)
     {
            var IK;
            var RK = new Array();
            RK[0] = 13
            if(window.Event)
                IK = e.which;
            else
                IK = e.KeyCode;
            for(var i; i < RK.length; i++)
            {
                if(IK == RK[i])
                    e.returnValue = false;
                else
                {
                    if(IK > 47 && IK < 58) 
                    {
                        e.returnValue = false;
                    }
                }
            }
     }

  • Re: ASP.Net Navigation/Validation STRANGE PROBLEM

    03-16-2007, 5:34 PM
    • Loading...
    • Dhuka
    • Joined on 03-15-2007, 8:52 AM
    • Posts 110

    Thank you Imran for your reply and ur solution. But I would prefer some formal way of resolving this problem not necessarily a javascript code as I have been avoiding javascript in my web application unless necessary.

    Please keep me posted about any other solution that you may have.

    Regards,

    Zulfiqar Dhuka

  • Re: ASP.Net Navigation/Validation STRANGE PROBLEM

    03-18-2007, 3:44 AM
    • Loading...
    • imran.nathani
    • Joined on 04-07-2006, 9:32 AM
    • Toronto,Canada
    • Posts 836

    what is your defination of formal way??

    hitting the "ENTER" is more of a client side event ,hence i decided on javascript.....however if u findsomething else let me know.

  • Re: ASP.Net Navigation/Validation STRANGE PROBLEM

    03-18-2007, 6:16 AM
    • Loading...
    • Dhuka
    • Joined on 03-15-2007, 8:52 AM
    • Posts 110

    Hey there 

    Well by formal i meant of any solution that microsoft itself offers or has proposed like any function or anything that could prevent the problem from happening.

    You proposed me javascript solution but like i said i am kinda hesitant in going for a javascript solution.

    By the way have you faced similar problem that I am facing in any of your projects????? 

  • Re: ASP.Net Navigation/Validation STRANGE PROBLEM

    03-18-2007, 6:28 AM
    • Loading...
    • imran.nathani
    • Joined on 04-07-2006, 9:32 AM
    • Toronto,Canada
    • Posts 836

    yes i have but i use the above solution........there is an MS-AJAX component that would restirct the keystrokes. but again thats AJAX .....another form of javascript function.

    if microsoft offers javascript on IE......y r u so hesitant on using javascript?.....does it give u nightmares?

  • Re: ASP.Net Navigation/Validation STRANGE PROBLEM

    03-18-2007, 7:20 AM
    • Loading...
    • Dhuka
    • Joined on 03-15-2007, 8:52 AM
    • Posts 110

    well it's not about having nightmare or anythin but about taking a wise decision...if I know some language then it doesn't mean i go on creating new and new piece of code whenever i need any without even investigating if there is any way or code already available already to resolve the issue from any authenticated body and i believe Microsoft is way too better than you and me atleast so any solution that may come from them must be better than wat u and I can think of.

    anywayz...thanks for you help

     

  • Re: ASP.Net Navigation/Validation STRANGE PROBLEM

    03-18-2007, 7:35 AM
    • Loading...
    • imran.nathani
    • Joined on 04-07-2006, 9:32 AM
    • Toronto,Canada
    • Posts 836

    may be your right........ making the right decision is very important.

    also pls post the solution here if u find it.

  • Re: ASP.Net Navigation/Validation STRANGE PROBLEM

    03-18-2007, 7:54 AM
    • Loading...
    • Dhuka
    • Joined on 03-15-2007, 8:52 AM
    • Posts 110
    sure
Page 1 of 1 (9 items)
Microsoft Communities
Page view counter