1

.net にコメントを追加するときに Twitter のようなメッセージを表示する関数を作成しました。

vb の関数:

 Dim script As String = ""
        script &= "  function ErrorMessage121212(TextClass, Error, MainDiv) { "
        script &= "     MainDiv = '#' + MainDiv;"
        script &= "      $(MainDiv).append(""<div align='center' id='overlaytext' style='margin-top:10px'></div>"");"
        script &= "    $(MainDiv).css('color', 'white');"
        script &= "      $(MainDiv).css('align', 'center');"
        script &= "       $(MainDiv).css('backgroundColor', 'black');"
        script &= "       $(MainDiv).css('display', ""none"");"
        script &= "      $('#overlaytext').html(""<b>"" + Error + ""</b>"");"
        script &= "         if (TextClass == """") {"
        script &= "          }"
        script &= "      else { "
        script &= "     $('#overlaytext').addClass(TextClass);"
        script &= "                 }"
        script &= "    $(MainDiv).fadeIn(1000, function () { $(MainDiv).fadeOut(1000); })"
        script &= "     }"
        script &= " ErrorMessage121212('" & MessageCss & "','" & errormessage & "','" & DivID & "');"
        If Not Page.ClientScript.IsClientScriptBlockRegistered("s1") Then
          Page.ClientScript.RegisterClientScriptBlock(_page.GetType(), "s1", script)
        End If
        Return True
4

2 に答える 2

2

使用してみてください:

ScriptManager.RegisterStartupScript(_page, typeof(Page), Guid.NewGuid().ToString(), "alert('a');", true);
于 2012-11-29T07:25:01.450 に答える
1

以下のコードを試してみてください。

Dim script As String = ""
    script &= "  function ErrorMessage121212(TextClass, Error, MainDiv) { "
    script &= "     MainDiv = '#' + MainDiv;"
    script &= "      $(MainDiv).append(""<div align='center' id='overlaytext' style='margin-top:10px'></div>"");"
    script &= "    $(MainDiv).css('color', 'white');"
    script &= "      $(MainDiv).css('align', 'center');"
    script &= "       $(MainDiv).css('backgroundColor', 'black');"
    script &= "       $(MainDiv).css('display', ""none"");"
    script &= "      $('#overlaytext').html(""<b>"" + Error + ""</b>"");"
    script &= "         if (TextClass == """") {"
    script &= "          }"
    script &= "      else { "
    script &= "     $('#overlaytext').addClass(TextClass);"
    script &= "                 }"
    script &= "    $(MainDiv).fadeIn(1000, function () { $(MainDiv).fadeOut(1000); })"
    script &= "     }"
    script &= " ErrorMessage121212('" & MessageCss & "','" & errormessage & "','" & DivID & "');"
    If Not Page.ClientScript.IsClientScriptBlockRegistered("s1") Then
        ScriptManager.RegisterStartupScript(_page, _page.GetType, "s1", script, True)
          End If
    Return True
于 2012-11-29T08:31:53.810 に答える