[CLOSED] Ke Up

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Ke Up

    Hi...

    im using KeyUp hander to display the value in NF2 number field if user type the value from key board in NF1 number field..
    it is working fine if user type the value from key board,it is not working if i paste the value in NF1 with mouse..if i paste with key board it is working..
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication1.WebForm2" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <%@ Register src="WebUserControl2.ascx" tagname="WebUserControl2" tagprefix="uc1" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    
    
       
    </head>
    <body>
        <form id="form1" runat="server">
       <ext:ScriptManager runat="server" />
    
      
        <ext:Button ID="btn" runat="server" Text="New Window">
        <AjaxEvents>
        <Click OnEvent="btn_Click"></Click>
        </AjaxEvents>
        </ext:Button>
       
    
        <uc1:WebUserControl2 ID="WebUserControl21" runat="server" />
    
    
       
    
        </form>
    </body>
    </html>
    
    
     protected void btn_Click(object sender, AjaxEventArgs e)
            {
                WebUserControl21.show();
            }
    
    
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl2.ascx.cs"
        Inherits="WebApplication1.WebUserControl2" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <script src="JScript1.js" type="text/javascript" language="javascript"></script>
    
    <ext:Window ID="Window1" runat="server" Width="250" Height="100" ShowOnLoad="false" >
        <Body>
            <table>
                <tr>
                    <ext:NumberField ID="NF1" runat="server" EnableKeyEvents="true">
                    <Listeners>
                       <KeyUp Handler="Calculate();" />                                                
                    </Listeners>
                    </ext:NumberField>
                     </tr>
                     <tr>
                    <ext:NumberField ID="NF2" runat="server">
                    </ext:NumberField>
                </tr>
            </table>
        </Body>
    </ext:Window>
    
    
     public void show()
            {
                Window1.Show();
            }
    
    JScript1.js
    function Calculate()
     {
         var aa = WebUserControl21_NF1.getValue();
    
    
         WebUserControl21_NF2.setValue(aa);
    }
    Last edited by Daniil; May 31, 2011 at 10:39 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Please follow this link to get the info how to catch 'paste' event.
    http://forums.ext.net/showthread.php?10101
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    Please follow this link to get the info how to catch 'paste' event.
    http://forums.ext.net/showthread.php?10101
    but your link describes how to avoid copy & paste from user,i dont want to avoid copy paste..if user paste a value with mouse in numberfield NF1 then that value should be display in NF2..and im using coolite version 0.8.1.987
  4. #4
    Yes, there is no sample what you exactly need, but that thread demonstrates how to catch paste event.
  5. #5
    Quote Originally Posted by Daniil View Post
    Yes, there is no sample what you exactly need, but that thread demonstrates how to catch paste event.
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:NumberField runat="server">
            <Listeners>
                <AfterRender Handler="this.el.dom.setAttribute('onPaste', 'return false');" />
            </Listeners>
        </ext:NumberField>
        </form>
    </body>
    </html>
    this works fine for EXT.NET but im using coolite version 0.8.1.987 ,here i have not found AfterRender
  6. #6
    Please try Render in that version.
  7. #7
    Quote Originally Posted by Daniil View Post
    Please try Render in that version.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication1.WebForm3" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script src="JScript2.js" language="javascript" type="text/javascript"></script>
    </head>
    <body>
        <form id="form1" runat="server">
       <ext:ScriptManager ID="ScriptManager1" runat="server" />
    
        <ext:NumberField ID="NF1" runat="server" EnableKeyEvents="true">
                   
                    <Listeners>
                       <KeyUp Handler="Calculate();" />     
                      <Render Handler="this.el.dom.setAttribute('onPaste', 'return false');" />                                           
                    </Listeners>
                    </ext:NumberField>
                   
                    <ext:NumberField ID="NF2" runat="server">
                    </ext:NumberField>
        </form>
    </body>
    </html>
    
    JScript2.js
    
    function Calculate() {
        var aa = NF1.getValue();
    
    
        NF2.setValue(aa);
    }
    But it is allowing to paste...
  8. #8
    Hi,

    Please investigate the following articles
    http://www.coderanch.com/t/117705/HT...tion-textfield
    http://www.articlesbase.com/programm...t-1003078.html

    IMHO it is bad idea to prevent paste to the field because you are altering default browser behaviour, if you afraid that a user can input wrong value then my advice: never rely on client side validation, if user want to paste any known value then fine, you will check that value on the server side. I think client side validation from Ext.Net is enough for informing the user therefore prevent the paste is not good idea (in any case real validation must be performed on the server)
    Last edited by Vladimir; May 20, 2011 at 8:06 AM.
  9. #9
    Quote Originally Posted by Vladimir View Post
    Hi,

    Please investigate the following articles
    http://www.coderanch.com/t/117705/HT...tion-textfield
    http://www.articlesbase.com/programm...t-1003078.html

    IMHO it is bad idea to prevent paste to the field because you are altering default browser behaviour, if you afraid that a user can input wrong value then my advice: never rely on client side validation, if user want to paste any known value then fine, you will check that value on the server side. I think client side validation from Ext.Net is enough for informing the user therefore prevent the paste is not good idea (in any case real validation must be performed on the server)
    okay thank you for your suggestion,i'll follow your suggestion...i'll not prevent paste...then tell me, im using keyup handler in number field,if user paste any value with keyboard the javascript is working fine..if user paste a value with mouse ,it is not working..how to solve this?


    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication1.WebForm3" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script src="JScript2.js" language="javascript" type="text/javascript"></script>
    </head>
    <body>
        <form id="form1" runat="server">
       <ext:ScriptManager ID="ScriptManager1" runat="server" />
     
        <ext:NumberField ID="NF1" runat="server" EnableKeyEvents="true">
                    
                    <Listeners>
                       <KeyUp Handler="Calculate();" />    
                                          
                    </Listeners>
                    </ext:NumberField>
                    
                    <ext:NumberField ID="NF2" runat="server">
                    </ext:NumberField>
        </form>
    </body>
    </html>
     
    JScript2.js
     
    function Calculate() {
        var aa = NF1.getValue();
     
     
        NF2.setValue(aa);
    }
  10. #10
    Hi,

    KeyUp listen keybord only, when you paste something by mouse we have no such events to catch it.
    In any way validation will be performed on blur event and pasted value will be checked
Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions