回车键插入asp.net多行文本框控件换行符 [英] enter key to insert newline in asp.net multiline textbox control

查看:831
本文介绍了回车键插入asp.net多行文本框控件换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些C#/ asp.net code我继承了具有我想要多行文本框。我这样做是通过添加文本模式=多行,但是当我尝试插入一个换行符,回车键,而不是提交表单:P

I have some C# / asp.net code I inherited which has a textbox which I want to make multiline. I did so by adding textmode="multiline" but when I try to insert a newline, the enter key instead submits the form :P

我GOOGLE了四周,这似乎是默认的行为应该是输入(或控制输入)来插入一个换行符。就像我说我继承了code,所以我不知道是否有JavaScript的胡闹周围或者如果有只是一个简单的asp.net的事情我必须做的。

I googled around and it seems like the default behavior should be for enter (or control-enter) to insert a newline. Like I said I inherited the code so I'm not sure if there's javascript monkeying around or if there's just a simple asp.net thing I have to do.

推荐答案

原来这是用Firefox + ASP.NET中的错误,其中的defaultButton的东西产生的JavaScript不工作在Firefox。我所描述的把一个替换为WebForm_FireDefatultButton功能这里

It turns out this is a bug with Firefox + ASP.NET where the generated javascript for the defaultButton stuff doesn't work in Firefox. I had to put a replacement for the WebForm_FireDefatultButton function as described here:

function WebForm_FireDefaultButton(event, target) {
    var element = event.target || event.srcElement;
    if (event.keyCode == 13 &&
    !(element &&
    element.tagName.toLowerCase() == "textarea"))
    {
        var defaultButton;
        if (__nonMSDOMBrowser)
        {
            defaultButton = document.getElementById(target);
        }
        else
        {
            defaultButton = document.all[target];
        }
        if (defaultButton && typeof defaultButton.click != "undefined")
        {
            defaultButton.click();
            event.cancelBubble = true;
            if (event.stopPropagation)
            {
                event.stopPropagation();
            }
            return false;
        }
    }
    return true;
}

这篇关于回车键插入asp.net多行文本框控件换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆