Avatar of dvplayltd
dvplayltd
Flag for Bulgaria asked on

Need a recommendation for ASPX code – a message to the user.

Dear experts

I’m a professional programmer with 10+ years in business, but new to ASPX coding and need little help. When my user click on Submit button I do some check with such kind of code:
            if (byteState == 2)
            {
                Page.RegisterStartupScript("codice", "<script>alert('User with such email already extist! Probably this mean that this user is already register and do not need new registration!');</" + "script>");
                txtMail.Focus();
                return;
            }

It works, but I get warning that this metod is decprated. Could you recommended me what code I should use? Also, please give me example how I’m possible to show new line in the message.

 Other metod I use for message to the customer is with this code:
                    CustomMessage = "alert('Unexpected error in spUsers save record to local DB');";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "CustomMessage", CustomMessage, true);

It is provided from this library:
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

Is this a good option? It look to me that it require to load a whole script library between 10 and 15 kb. In size, is that true???

 My primary dermands is
1)      To use a standart commands, which will be supported in next 5 years from all WEB brousers.
2)      To save internet traffic.
ASP.NET

Avatar of undefined
Last Comment
dvplayltd

8/22/2022 - Mon
alhalama

You can accomplish this without the AJAX Extensions by using a Literal on your page that you can put script into:

<Literal runat="server" EnableViewState="false" id="javaScriptPlaceHolder"/>

In code you would then set the text of the Literal to be your script:

javaScriptPlaceHolder.Text = CustomMessage;

To control when you show the script you can either move it on the page or put it within a function that you call from the onload event of the body.
dvplayltd

ASKER
Do not seem very practical ... how, where to move code? I prefer to use a solution in c# code only.
SOLUTION
alhalama

THIS SOLUTION 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
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
dj_alik

THIS SOLUTION 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
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
dvplayltd

ASKER
To alhalama

"I would recommend taking time to learn the platform that you are on and understand what you are doing. "

 You are damm right, but who and for what have enoght time to go to details??? In our world where the final result should be done for impossible short time ...

To dj_alik

Your answer is very precise, thank you! I'll use it.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23