Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on 

Problem to show message

Hi,
I cannot show the message prompt properly, by the following. Why?

function showMsg0() {
    $.message({
        title: '信息',
        content: 'new或NEW是保护字,不可以选为名字简称!',
        buttons: {
            OK: {
                text: 'OK',
                btnClass: 'btn-green',
                keys: ['enter'],
                action: function () {
                    //$.alert('You clicked OK!');
                }
            },
        }
    });
    return false;
};
...
        protected void userabbr_post_change(object sender, EventArgs e)
        {
            if (tb_userabbr.Text.ToUpper() == "NEW")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showMsg0()", true);
                tb_userabbr.Text = "";
                return;
            }
        }

Open in new window

ASP.NET.NET ProgrammingCSSJavaScriptProgramming Languages-Other

Avatar of undefined
Last Comment
Ryan Chong
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

are you forgot to include the message notification library into your page?

you probably hitting an error:

TypeError: $.message is not a function

Open in new window

Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

ASKER

To

http://my-friend.co/UserMaintenance2/Default.aspx?userid=new&readonly=n

I input "new" to 1st field, but I got no message being shown.
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

you may try to solve this javascript error first..

SyntaxError: missing ) after argument list
[Learn More]
Default.aspx:352:27

Open in new window

Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

ASKER

Sorry, where is the Javascript error?
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

probably this line:

javascript:alert('登入者名称 - ''NEW'' 错误。');(function() {var fn = function() {$get("ctl08_HiddenField").value = '';Sys.Application.remove_init(fn);};Sys.Application.add_init(fn);})();

Open in new window

Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

ASKER

How do you get such error message? I can see no problem, within the project (in Visual studio).
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

How do you get such error message? I can see no problem, within the project (in Visual studio).
try check that in your web browser's Inspect feature.

i'm using FF, for your info.
Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

ASKER

Sorry, how to correct this

Uncaught SyntaxError: missing ) after argument list
in the following

function showMsg0() {
    $.message({
        title: '信息',
        content: 'new或NEW是保护字,不可以选为名字简称!',
        buttons: {
            OK: {
                text: 'OK',
                btnClass: 'btn-green',
                keys: ['enter'],
                action: function () {
                    //$.alert('You clicked OK!');
                }
            }
        }
    });
    return false;
};

Open in new window

Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Uncaught SyntaxError: missing ) after argument list

i found this error at code below instead:

javascript:alert('登入者名称 - ''NEW'' 错误。');(function() {var fn = function() {$get("ctl08_HiddenField").value = '';Sys.Application.remove_init(fn);};Sys.Application.add_init(fn);})();

can you probably remark it for testing purposes if you unable to solve it?
Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

ASKER

Sorry, is there any problem to this?
function showMsg0() {
    $.message({
        title: '信息',
        content: 'new或NEW是保护字,不可以选为名字简称!',
        buttons: {
            OK: {
                text: 'OK',
                btnClass: 'btn-green',
                keys: ['enter'],
                action: function () {
                    //$.alert('You clicked OK!');
                }
            }
        }
    });
    return false;
};

Open in new window

Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Sorry, is there any problem to this?
as tested earlier, i get this error:

TypeError: $.message is not a function

Open in new window


are you forgot to include the message notification library into your page?

re-tested the website and it seems that you have not fixed it yet
Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

ASKER

are you forgot to include the message notification library into your page?

What library should be added?
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

>>What library should be added?

I believe this library was being used to generate the pop-up message.

what scripts are you included in order to do that? are you forgot to include it?
Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

ASKER

I already had such codes
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script type="text/javascript" src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>    
    <script type="text/javascript" src="//code.jquery.com/jquery-2.1.3.min.js"></script>
    <script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.3/jquery-confirm.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.css" />
    <link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.3/jquery-confirm.min.css" />

Open in new window

to the page.

Now, there is originally, no mentioned problem to the page. Problem only arises, after I've entered 'new' to 1st field, on the page.

If I clicked that error, it was pointing to such part below

JavaScript1.js:281 Uncaught TypeError: $.message is not a function
    at showMsg0 (JavaScript1.js:281)
    at Default.aspx?userid=new&readonly=n:352

Open in new window

If I click error in above, it does point to this
<script type="text/javascript">
//<![CDATA[
(function() {var fn = function() {$get("ctl08_HiddenField").value = '';Sys.Application.remove_init(fn);};Sys.Application.add_init(fn);})();showMsg0()//]]>
</script>

Open in new window

greetings HuaMinChen, , , not sure I can help? ? , , but I have looked at the page code, and the comments here,  I will first say something about this error -
      javascript:alert('登入者名称 - ''NEW'' 错误。');(function() {var fn = function() {$get("ctl08_HiddenField").value = '';Sys.Application.remove_init(fn);};Sys.Application.add_init(fn);})();

Open in new window


In this you have too many single quotes on the word - NEW - as
        ''NEW''

it should be just single quotes as -
        'NEW'
not two quotes

- - - - - - - - - - - - - - -

Now in the -
     function showMsg0() {

you try and use an incorrect method as the message -
          $.message({

you can change this incorrect .message, , so you use a Jquery UI    .dialog    method to show a pop-up message, , however I searched and searched and I could not find any use or call in your javascript to the function
     showMsg0( )

and your code looks like it is just a TEST FUNCTION not ever used, you may should just delete from your code the entire   showMsg0( )   function? ?
Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

ASKER

Many thanks Slick.

Is it a problem to call JS event in Code behind like the following

                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "showMsg0()", true);
				...
function showMsg0() {
    $.message({
        title: '信息',
        content: 'new或NEW是保护字,不可以选为名字简称!',
        buttons: {
            OK: {
                text: 'OK',
                btnClass: 'btn-green',
                keys: ['enter'],
                action: function () {
                    //$.alert('You clicked OK!');
                }
            }
        }
    });
    return false;
};

Open in new window


Where do you still see ''NEW'', on the page?
SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

ASKER

How to identify the problem to run this event?
function showMsg0() {
    $.message({
        title: '信息',
        content: 'new或NEW是保护字,不可以选为名字简称!',
        buttons: {
            OK: {
                text: 'OK',
                btnClass: 'btn-green',
                keys: ['enter'],
                action: function () {
                    //$.alert('You clicked OK!');
                }
            }
        }
    });
    return false;
};

Open in new window


The original issue is due to problem (on Web page) to run this event.
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

ASKER

Thanks a lot.
Using these
function showMsg0() {
    $.dialog({
        title: '信息',
        content: 'new或NEW是保护字,不可以选为名字简称!',
        buttons: {
            OK: {
                text: 'OK',
                btnClass: 'btn-green',
                keys: ['enter'],
                action: function () {
                    //$.alert('You clicked OK!');
                }
            }
        }
    });
    return false;
};

Open in new window

I cannot show OK button below. What to adjust?
User generated image
SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo