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

LVL 12
HuaMin ChenProblem resolverAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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

0
HuaMin ChenProblem resolverAuthor Commented:
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.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
you may try to solve this javascript error first..

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

Open in new window

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

HuaMin ChenProblem resolverAuthor Commented:
Sorry, where is the Javascript error?
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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

0
HuaMin ChenProblem resolverAuthor Commented:
How do you get such error message? I can see no problem, within the project (in Visual studio).
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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.
0
HuaMin ChenProblem resolverAuthor Commented:
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

0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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?
0
HuaMin ChenProblem resolverAuthor Commented:
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

0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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
0
HuaMin ChenProblem resolverAuthor Commented:
are you forgot to include the message notification library into your page?

What library should be added?
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
>>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?
0
HuaMin ChenProblem resolverAuthor Commented:
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

0
Slick812Commented:
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? ?
0
HuaMin ChenProblem resolverAuthor Commented:
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?
0
Slick812Commented:
Sorry, I have told you that the -
    ''NEW''
was in a different place in your code the  ''NEW'' is NOT in that    function showMsg0() {   code.
I told you that the code as -
     $.message({
was Not correct, and can not work, , and if you need to use this code function to work then you will need to use another way to show a pop up message, you can not use    $.message({     to do that.


I do not really understand when you say this -
    "Is it a problem to call JS event in Code behind like the following"
I do not know what "Code behind" means to you?
0
HuaMin ChenProblem resolverAuthor Commented:
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.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
ok, it seems that you're using jquery-confirm:

https://craftpip.github.io/jquery-confirm/

? if yes, there is no option defined for $.message , try use: $.dialog instead.

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

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HuaMin ChenProblem resolverAuthor Commented:
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?
20v.png
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
I cannot show OK button below. What to adjust?

my bad.. try use:

$.alert

instead
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.