C# PreviewKeyDown Event - Allow Special Characters

Hello,
I have a textbox and a PreviewKeyDown Event in which i want to allow Special Characters,A-Z and 0-9 only. Other keys such as keyboard modifiers, F1-F12, Esc,Tab, etc are not allowed.
private void PART_SearchText_PreviewKeyDown(object sender, KeyEventArgs e)
TextBox searchTextBox = sender as TextBox;
if (((e.Key >= Key.A && e.Key <= Key.Z)
|| (e.Key >= Key.D0 && e.Key <= Key.D9)
|| (e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9)
|| (e.Key == Key.Back || e.Key == Key.Delete))
&& (Keyboard.Modifiers != ModifierKeys.Shift)
&& (Keyboard.Modifiers != ModifierKeys.Alt)
&& (Keyboard.Modifiers != ModifierKeys.Control)
&& (Keyboard.Modifiers != ModifierKeys.Windows)
&& (searchTextBox.SelectedText.Length > 0 && searchTextBox.Text.Length > 0)
&& (searchTextBox.SelectedText.Length == searchTextBox.Text.Length))
if (SearchDeletionCommand != null)
searchTextBox.IsReadOnly = false;
SearchDeletionCommand.Execute(null);
The issue I am facing when hitting special characters (!,@,#...).
So on my laptop if i press Shift 1, i am eventually entering a punctuation mark (!) and that should work. But in above code what happens is that the conditions does not get satisfied.
Thanks,
Abdi

Thanks.
I was thinking to use ascii values. 
private void PART_SearchText_PreviewKeyDown(object sender, KeyEventArgs e)
TextBox searchTextBox = sender as TextBox;
int ascii = KeyInterop.VirtualKeyFromKey(e.Key);
if (ascii >= 32 && ascii <= 127 && (searchTextBox.SelectedText.Length > 0 && searchTextBox.Text.Length > 0)
&& (searchTextBox.SelectedText.Length == searchTextBox.Text.Length))
if (SearchDeletionCommand != null)
searchTextBox.IsReadOnly = false;
SearchDeletionCommand.Execute(null);
I am using  int  ascii = KeyInterop.VirtualKeyFromKey(e.Key); to get the ascii value but it does not give me the correct ascii values. For eg.. ascii value for comma is generally 88 but over here it gives me 148 or something. And that is when my
logic above fails.
Is there any workaround for this?
Thanks,
Abdi

Similar Messages

  • Not allowed Special characters

    Hi Gurus,
    iam getting an error while activating the DSO request
    The error is 
    u201CValue 'E Byron Car Realignment' (hex. '450020004200790072006F006E002000430061007200200052') of characteristic ZCOITEMTX contains invalid charactersu201D
    I donu2019t understand what invalid character it is containing
    Apart from this I am getting error for the special character u201C|u201D
    How to use both the special characters at RSKC
    Please suggest
    Thank you

    Hi,
         According to me ZCOITEMTX is not allowing lower case. you can check for this infoobject in RSD1, at General tab Lowercase Letter check box is check or not?
    this will solve your issue.
    regards,

  • Create / Alter user doesn't allow special characters in password

    When i try to change the password from say : vos1s05 to : vos1s05! i get the error message (missing or invalid option), i have used several special characters and all give the same error, is there a way to circumvent this, or will this be enabled in a new release ??

    A password is classified as an oracle identifier and must conform to the rules for indentifiers. To include special characters you need to enclose it in double quotes e.g. "vos1s05!"

  • Allowing Special Characters in email subject

    Hi All,
    This is my first post..Here is my scenario..I have an application whereby i can send emails..I tried sending anemail with special character in subject but the recipient had a different character when received..So i changed the encoding type of message to UTF-8 and it worked perfectly..But it didnt support for all the special characters.
    Is there any way by which i can send any special character in emails without any problem..This is an urgent requirement
    Thanks in Advance

    aajan_1127 wrote:
    Thanks for the reply..
    I have a text box in jsp where by the user can enter values for the suject..So in servlet, the values enterd in text box will be the subject of the corresponding email.. ANd also am not using any unicode..the subject comes as a string and then i encode the values..You might want to brush up on what strings are and what unicode means. Inside Java strings are unicode. But if you are sending/receiving the data in unicode through the JSP / servlet depends on the encoding set on the JSP page. If you are not receiving unicode data, you are already missing those 'special' characters before even sending the email.

  • Allowing special characters in bw

    Hello Friendz,
    I have loaded transaction data in psa and infocube.
    For some values in R/3 its showing following error.
    <b>Value '0000cj1000 ' (Hex ' ') of char. 0REF_DOC_NO contains unauthorized characters.</b>
    I tried to solve this using rskc,but still i didn't get the solution.
    How can i get rid of this?
    Plz,help me for this,its really urgent.

    Hi,
    Make sure that Lower case letters are allowed for this infoobject. You can make it allow by selecting ckeck box of 'lower case letters' in Infoobject maintainance of 0REF_DOC_NO .
    Other wise .
    Convert value to upper case in transfer rule.
    With rgds,
    Anil Kumar Sharma .P
    Message was edited by: Anil Kumar Sharma

  • [HELP] Incoming SMS problem with special characters

    Hello,
    I have my BlackBerry Q10 for 4 days and I'm geting used to it and I love it but that's not the case...
    I live in Latvia and we use special letters in our language input like
    "ā č ē ž ļ ņ š ī ķ ģ ū" and that's alright with me, I know that I can't send these letters with my blackberry!
    But everytime my girlfriend sends me messages that are larger than two sentences and with these special letters... then I just can't read them at all. It looks like this:
    As you can see in image 1 & 2 there are @ symbols between every letter and other symbols.
    In the second image there you can see that the first sentence is taken from the same sms which is in image 1, it's just separated, It would be annoying to separate every single message someone sends me!!!!
    And in this image 3 below, you can see the correct text which is shown in image 2 with @ symbols between the letters...
    Please, I would appreciate it if someone could help me with this problem, it's annoying!
    P.S. And yes I have "Allow Special Characters" turned from OFF to ON in Text Messages>Settings>Advanced and it DIDN'T HELPED!
    Don't know what else to do!!!

    Ok, solved:
    From, DW do Edit | Preferences | New Document and set the Default Encoding to
    whatever you wish it to be.  That will set the default for all new
    documents in Dreamweaver.
    For the existing pages, you will need to open them and do Modify | Page Properties | Title/Encoding to set the encoding as you desire.

  • Seeburger passing special characters

    Hi
    does anyone know the parameter to be set to allow special characters to be processed in BIC mapping designer
    Thanks
    Pratichi Chauhan

    Hi,
    Special character like what?
    Regards
    Ivan

  • ENS for Calendar Server strange issue when handling special characters

    The problem is basically that the ENS message isn't fully flushed to the stream when the generated event (an appointment creation for example) has special characters such as "ñ", "á","é". Maybe are encoded in more than one byte but it flushes the buffer using characters * character_size and character_size is not always 1.
    If I make a second appointment the buffer is flushed and I get the rest of the first notification and the new one.
    Perhaps it is a configuration case and I should configure ENS to support more languages.
    Could you help me?
    Thank you,
    Best regards.

    Thank you Shane.
    I've run the sample and it works fine.
    Perhaps it's not a bug but it's very strange the behaviour ens has with events with special characters. This is what I do step by step:
    1. I subscribe for all events and all the users
    2. I create and appointment with special characters
    3. I receive the event notification
    GAP/1.0 1b 3 1915 enp:///ics/caleventcreate?calid=[email protected]&uid=000000000000000000000000000000000b2c934cc04e0000140000001f130000&rid=0|ntfy|00000000
    The number 1915 should be the message length so I try to read 1915 bytes. However I can only read 1903 bytes. In this 1903 I have the full xml with the vcalendar.
    4. I create a second appointment
    5. The message I received is something like "\0\0\0\0\0\0\0\0\0\0\0\0" which is 1915-1903
    6. I have to discard this message because it's invalid
    7. I receive the event notification
    I can fix my custom client and discard this "\0\0\0..." messages but It's a strange behaviour. Perhaps the protocol is as is but I thought it was a bug.
    Thank you Shane.

  • How to you enforce special characters under Authentication in the CMC?

    Is there a way to to enfoce special characters in the password for user authentication?  I do know BO XI R2 SP3 does allow special characters, but I would like to notify users when they get prompt to change their password.

    Margaret,
    Using the CMC, navigate to the entry entitled "Authentication", next choose the tab "Enterprise".
    There are two key options (they appear towards the top), and here is a brief explanation of these:
    When you enable the enforce mixed-case passwords option, then it ensures that passwords contain at least two of the following character classes: upper case letters, lower case letters, numbers, or punctuation.
    The second option, must contain at least (N) characters stipulates the minimum length that a user can choose for his or her password.
    From a practical point of view, I would say that if you have the first option taken (enforce mixed-case), then your next option should be set at no lower than 8.
    As far as educating the user, this is done externally from the web page when it presents to the user (the user gets three prompts:  old password, new password, and re-type new password).  As far as a clue to using at least two of the upper/lower/number/punctuation in their password, I don't know how you communicate that other than an internally circulated "Introduction to Our System" handout and you include this tidbit amongst other details you'd like your users to know, etc, etc.
    Thanks,
    John

  • XML Gateway - Hub Definition Password - Special Characters

    Our Marketplace provider is about implement mandatory special characters in the hub access user accounts. Our current configuration does not allow special characters in the hub definition.
    It there anyway to enter any symbol in the XML Gateway>Hub Definition>Password field.
    1) Are there any symbols that are not deemed "Special Characters", I have tried various without success.
    2) Can the password type be changes to allow symbols?
    Any help welcomed,
    Simon
    Swansea
    UK

    Actually this is the right forum to be in
    There are a few steps you need to do to configure BPEL with XML Gateway. This is what you did in 11i, may have changed for R12
    Here are the steps to setup BPEL output
    1. Choose responsibility 'XML Gateway' from left panel.
    2. From right panel choose 'Define Lookup Values' . Oracle forms application would open up.
    3. On XML Gateway Lookups form , press F11.
    4. In 'Type' field enter 'COMM_METHOD'(without quotes.
    5. Press CTRL+F11 . Form would fill from already present look ups. We are going to create new Lookup Value.
    6. On new row create look up as (Values without quotes) :
    - Code = 'BPEL'
    - Meaning = 'BPEL'
    - Description = 'Used for Apps Adapter Integration using BPEL'
    - Check 'Enabled' checkbox.
    7. Save form from File--> Save from menu bar. you can close this form.
    8. XML Gateway Navigator form would be presented.
    9. From right panel choose 'Define Trading Partners' .
    10. On Trading Partner Setup form , press F11 .
    11. In field 'Trading Partner Type' enter 'Supplier (without quotes).
    12. In field 'Trading Partner Name' enter ‘VENDOR-1' (without quotes).
    13. Go to Trading partner details and create new transaction as (Values without quotes)
    - Connection/Hub = 'DIRECT'
    - Protocol Type = 'BPEL'
    - Protocol Address = 'http://appsadapter.sample.com'
    cheers
    James

  • SRT Framework exception: ICF: Error when creating service node. [rc:wrong_icf_name] No special characters allowed in name

    Hi,
    I have created a web service in SAP ECC from a RFC.
    While configuring the web service in SOA management to publish it, getting error SRT Framework exception: ICF: Error when creating service node. [rc:wrong_icf_name] No special characters allowed in name
    How to resolve the same.
    Thanks
    Tanmay

    Hello Tanmay,
    Are you including quotes (') in the name, I assume not?
    Regards,
    Siddhesh

  • CONSTRAINT rule of no special characters allowed? Help

    ALTER TABLE dbo.tblasset ADD CONSTRAINT
    CK_tblasset_HardwareNumber CHECK ([HardwareNumber]<>'' and [HardwareNumber] is not null)
    GO
    Is there away I can implement special characters being inputted on a NVARCHAR datatype using this?special characters like (* , . ,")Many thanks

    ALTER TABLE dbo.tblasset ADD CONSTRAINT
    CK_tblasset_HardwareNumber CHECK ([HardwareNumber]<>'' and [HardwareNumber] is not null)
    GO
    Is there away I can implement special characters being inputted on a NVARCHAR datatype using this?special characters like (* , . ,")Many thanks
    Your can create a Check
    Constraint on this column and only allow Numbersand Alphabets to
    be inserted in this column, see below:
    Check Constraint to only Allow Numbers & Alphabets
    ALTER TABLE Table_Name
    ADD CONSTRAINT ck_No_Special_Characters
    CHECK (Column_Name NOT LIKE '%[^A-Z0-9]%')
    Check Constraint to only Allow Numbers
    ALTER TABLE Table_Name
    ADD CONSTRAINT ck_Only_Numbers
    CHECK (Column_Name NOT LIKE '%[^0-9]%')
    Check Constraint to only Allow Alphabets
    ALTER TABLE Table_Name
    ADD CONSTRAINT ck_Only_Alphabets
    CHECK (Column_Name NOT LIKE '%[^A-Z]%')
    Source: http://stackoverflow.com/questions/25408483/create-rule-to-restrict-special-characters-in-table-in-sql-server
    web: www.ronnierahman.com

  • Special Characters and spaces in Tablenames and Column Names are allowed ?

    Hi
    I have created two tables in Oracle10g
    as follows
    SQL> create table test(columna number,columnb varchar2(20),primary key(columna));
    Table created.
    SQL> insert into test values(1,'test');
    1 row created.
    SQL> commit;
    COMMIT är utfört.
    SQL> create table "test quote"("#" number,abc number,primary key("#"));
    Table created.
    SQL> insert into "test quote" values(1,2);
    1 row created.
    SQL> commit;
    COMMIT är utfört.
    SQL> select * from "test quote";
    # ABC
    1 2
    SQL> select * from test;
    COLUMNA COLUMNB
    1 test
    Now I want to cache the tables and their data into TimesTen
    The cache group for table test which is not having any spaces and special characters in table name and column names is created perfectly.
    But when I create the cache group for table "test quote" which is having special characters and spaces it gives error :
    Command>create readonly cache group w2 from testuser.test(columna number,columnb varchar2(20),primary key(columna));
    Command>select * from test;
    <1,test>
    1 row found.
    Command>create readonly cache group w3 from testuser."test quote"("#" number,abc number,primary key("#"));
    5140: Could not find TESTUSER.TEST QUOTE in Oracle. May not have privileges.
    Command Failed.
    Now there is contradiction that why cache group for table test is created successfully and why it is not being created for table "test quote".
    What I think is if special characters and spaces in column names and table names are possible in Oracle then it sould be possible in TimesTen.
    Any possible solution.
    Looking forward for your reply.
    Please help I am stuck badly.
    /Ahmad

    Hi
    Problem Solved ....... Remeber only Capital letters work with special characters ......
    /Ahmad

  • I have a Flash Sample to rotate images and text but I not find a way to display special characters

    Hello everyone.
    I bought a very nice Flash application that rotate images, and text of any color and size. It use an XML input file.
    I've posted here, a complete copy, so any of you can download, view and use it freely.
    I would appreciate if any of you know how to do, so that the text displayed, including the characters I use in my language (Spanish), such as á, é, í, ó, ú, ñ, and other special characters.
    In fact, I could not find a way to do it, because I'm not expert Flash, and less in ActionScript.
    If any of you would help me on that, I thank you implement the appropriate adjustments and compressed into a. zip file, and let me know where to download it, or if you prefer you can send it to my email: [email protected]
    After all compressed in .zip format is a very small file: 430K.
    Click here to download the complete sample.
    Thanks.
    =====================================
    Translated using http://translate.google.es
    =====================================

    Hello Rinus,
    If I understood your last post correctly, then problem 2 is resolved, right?
    Regarding problem 3:
    I'm not asking you to share exact VIs.
    I just want to see a very simple VI that explains the concept of what you're trying to do, what should happen (this can be in words that refer to the front panel elements) and what you've tried.
    The terminology you're using isn't clear to me without an extra explanation.
    This could even be only a Front Panel with a few buttons on where you just describe what should happen with specific controls/indicators.
    Based on the first post it is not clear to me what you mean with:
    - A "button element":
      Are you talking about a control, an indicator, a cluster that contains multiple control?
    - The structure:
      Is this an event structure, case structure, for loop, ...?
    Is it seems like you want to programmatically control Front Panel objects, which on itself is no problem at all independent of how many objects you want to control.
    Please share with me simple example of what goes wrong and explain which things should happen on that specific Front Panel.
    This will allow me to help you and also allow me to guide you along the right path.
    Kind Regards,
    Thierry C - Applications Engineering Specialist Northern European Region - National Instruments
    CLD, CTA
    If someone helped you, let them know. Mark as solved and/or give a kudo.

  • Handle special characters in xml

    Hi,
      Our end users tend to copy the description text from Word documents to pdf form and submits it.
    If that text contains any special characters, its getting carried to the extracted xml. In the next step, when I try to assign a task to user with template and this xml, Managers cannot able to open the form and showing the error. When I assign the xml without special characters, its running fine.
    Please assist on how to handle this?
    My expectation is that user should be prompted in the form when he pastes any special characters or they should be auto-corrected to null values. if that is not possible, atleast we should able to filter the xml and eliminate special characters before the form go to next stage.
    Appreciate your help.
    Thanks,
    Krishna

    In first instance, I would have followed this way:
    http://www.dvteclipse.com/documentation/svlinter/How_to_use_special_characters_in_XML.3F.h tml
    so, I would have parsed the submitted text in a Validate event and changed any special chars to UTF-8 numeric reference.
    However, I found this:
    http://blog.mark-mclaren.info/2007/02/invalid-xml-characters-when-valid-utf8_5873.html
    which seems to state that not all UTF-8 characters are possible in XML.
    In fact, those allowed are listed here:
    http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char
    so, I would still use a Validate event script but based on the XML specs' Character Range. Exactly as Mark McLaren did in Java.
    This will permit to keep those special chars that are allowed. Your Managers will thank you.
    Hope it helps.

Maybe you are looking for

  • Using threads to change button status

    Hi all im reworking my conway life adt and trying to build it into an ap (as i have it working as an applet) as applets have a repaint command then implementing the generations was pretty easy. However in an application i will have to use threads won

  • Changing data in MATMAS.

    Hi, How can we Change data in MATMAS IDoc Thanks, Malini.

  • Data loss during Pagination

    I have a dropdown selection box setup on a PHP page and its options coming from a MySQL database. When user selects an option, it will POST to another detail PHP page to list out all records. I used the recordset and server behavior functions in Drea

  • NW ftp 550 File Server unavailable

    FTP service running on one NW 6.5 sp8 server (//server6) in the tree. I have rights to all servers in the tree. All file servers are Netware 6.5 sp8 My home directory and default ftp directory is //server1/data/home/me. Within an ftp session I can cd

  • Request to refund for credit auto-recharge

    [Topic title updated by moderator to be more descriptive.] Please refund my autorecharged amount of $24.95 otherwise i will look at legal action. i havent used the account for over 2 years.