create a accessible dialog box for the error mesage

拥有回忆 提交于 2019-12-25 06:57:15

问题


I am working on a portal to make it accessible. For that it is required to make dynamic content focusable. In the login page, the Authentication error is dynamic content which is not getting focus when needed. Coding is done in razor engine C#

@if (TempData["error"] != null)
{
@Html.Raw(Resources.Strings.ResourceManager.GetString(TempData["error"].ToString()))
}

Where p="Authentication failed. Renter your Credentials."

In other attempt I had put it in alert box like this-

@if (TempData["error"] != null)
{
<script> alert("'+@Html.Raw(Resources.Strings.ResourceManager.GetString(TempData["error"].ToString())) +'");
</script>
 }

but it is not upto my expectation I need to customize it. So I am searching for the answer to providing a customizing popup box in place of this.

Is there any way to give focus on it by putting the error message in form of some dialog box. Or any other way of showing error message which is focusable.


回答1:


If you want more control you can use, jquery ui but its again sometime unnecessary with file size but have more control and easy feeling

function openConfirm() {
    var html = ''
        + '<div id="dvConfirm">'
        + '<div class="editor-main">'
        + '    <h6>'
        + '        @Html.Raw(TempData["error"].ToString())'
        + '    </h6>'
        + '</div>'
        + '<p class="continue_userprof">'
        + '    <input type="submit" value="Continue" onclick="onConfirmClick();" />'
        + '</p>'
        + '</div>';

    var div = $(html);


    div.dialog({
        title: "Title",
        close: destroy_this_dialog,
        height: 245,
        width: 420,
        modal: true,
        draggable: true
    });

    function destroy_this_dialog(event, ui) {
        $(this).dialog("destroy");
        $(this).remove();
    }
}


来源:https://stackoverflow.com/questions/27254081/create-a-accessible-dialog-box-for-the-error-mesage

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!