Wednesday, August 15, 2012

Multiline Textbox Problem when Clicking on Enter button

Multiline Textbox Problem when Clicking on Enter button
Hello All
In my silverlight4 application am using a textbox with multiline property.
what my problem is when i click on Enter button instead of going to next line it is Redirecting to home page.
the following is my code
</TextBox>
please help me out regarding this
Thanq
ch@/\/du
Answers & Comments...

Answer: 1You would expect the Enter button to produce a new line but it does not!  Instead you have to do this in code:
private void txt_additionaldetails_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {

            if (e.Key.Equals(Key.Enter))
            {
                TextBox MyBox = (TextBox)sender;
                MyBox.Text = MyBox.Text + "\r";
                MyBox.SelectionStart = MyBox.Text.Length;
            }
        }

by : 

Answer: 2Hi,
I test your code on my PC, it works fine. here is my code:
Orientation="Vertical">
            TextWrapping="Wrap" AcceptsReturn="True" Height="300" Text="I love Silverlighting!
                    I love Silverlighting!I love Silverlighting!I love Silverlighting!I love Silverlighting!">
            
            
        
private void Button_Click(object sender, RoutedEventArgs e)
        {
            String str = testTextBox.Text;
            MessageBox.Show(str);
        }
So I can't reproduce your scenario. Could you please what is the environment your issue occured? Do you have any other codes about the TextBox?
Looking forward to your reply.
Johnson
by : 

Answer: 3Hello John
I implemented your code but no use, still my enter button click redirecting me to Home page.
any other code would be appreciated.
any way thanks for your reply
by : 

Answer: 4Hello Johnson
I need to enter text at run time not in design any other help would be appreciated
by : 

Answer: 5Hi,
Try this:
txt2.AcceptsReturn = true;
If that still now working, please check if you bind enter button clicking event?
Best Regards,
Johnson
by : 

Answer: 6Are you by chance using a mac?  We had a weird issue where pressing the key would actually trigger the back button in the browser (which moved us to our login page). Maybe you've found another weird bug. 
by : 

Answer: 7Hello Cleon26
Am not using mac.
Am using Windows7 32-bit OS and am checking my output in IE8 and Google Chrome 21.0.1180.60 m
any other solution for this please....
by : 

Answer: 8Hi,
Could you please upload your repro project to skydrive and post download link here so that I can test it and distinguish whether it is environment specific issue?
Thanks

No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog