473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Displaying message in c#

Hi, I am displaying message in c# like this

Response.Write("<script>alert( 'Sum is 50' )</script>");
it is working fine,but it is not working when we take variable in aleart like

int a=25;
int b=25;
int sum=a+b;

Response.Write("<script>alert(sum)</script>");
this is not working.
anyone can solve my problem.

Shailesh Kumar
Jul 11 '07 #1
5 1405
r035198x
13,262 8TB
Hi, I am displaying message in c# like this

Response.Write("<script>alert( 'Sum is 50' )</script>");
it is working fine,but it is not working when we take variable in aleart like

int a=25;
int b=25;
int sum=a+b;

Response.Write("<script>alert(sum)</script>");
this is not working.
anyone can solve my problem.

Shailesh Kumar
Try
Expand|Select|Wrap|Line Numbers
  1.  Response.Write("<script>alert(''+sum)");
Jul 11 '07 #2
Plater
7,872 Expert 4TB
sum is a variable in your c# code, not your javascript, so you will need something like:
Expand|Select|Wrap|Line Numbers
  1. int a=25;
  2. int b=25;
  3. int sum=a+b;
  4.  
  5. Response.Write("<script>alert('"+sum.ToString()+"')</script>");
  6.  
Note: that inside the alert() I have included the ' on either side of the contents and not just a "
(So it's a ' followed by a " then +sum.ToString()+ then " then ' )
Jul 11 '07 #3
TRScheel
638 Expert 512MB
sum is a variable in your c# code, not your javascript, so you will need something like:
Expand|Select|Wrap|Line Numbers
  1. int a=25;
  2. int b=25;
  3. int sum=a+b;
  4.  
  5. Response.Write("<script>alert('"+sum.ToString()+"')</script>");
  6.  
Note: that inside the alert() I have included the ' on either side of the contents and not just a "
(So it's a ' followed by a " then +sum.ToString()+ then " then ' )
Wouldn't it be easier to just write it like:

Expand|Select|Wrap|Line Numbers
  1. Response.Write(string.Format("<script>alert('{0}')</script>", sum));
  2.  
Jul 11 '07 #4
Plater
7,872 Expert 4TB
Maybe, but I never liked the string formater. Reminds me too much of printf().

Wouldn't it be easier to just write it like:

Expand|Select|Wrap|Line Numbers
  1. Response.Write(string.Format("<script>alert('{0}')</script>", sum));
  2.  
Jul 11 '07 #5
TRScheel
638 Expert 512MB
Maybe, but I never liked the string formater. Reminds me too much of printf().
Ah, everyone has their quirks. I particularly like it. No right or wrong, I just thought in that example it would be easier to show what you were getting at like that.
Jul 11 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Paul M | last post by:
Hi there, i hope someone can help me out here.. I have a input screen where i want the user to enter text in 2 different languages, english and macedonian. How is it possible to make the...
1
by: Waguih Boctor | last post by:
Hi, I have a number of ASP pages where some JPGs and GIFs are displaying in the browser and some are not. I have included an excerpt from the HTML below. In this example, the gif file at the...
8
by: euang | last post by:
Hi, I have been using access 2000 for two years on WINDOWS NT to display dynamic aweb page using ASP My ISP has now changed to Windows 2003, and I am having major problems displaying...
2
by: Joe Price | last post by:
Hi chaps I've got an XML file, within that file i've embedded html code using the <!]> tag I'm displaying that xml file through a browser using an xsl style sheet. However it is displaying...
1
by: Yoshitha | last post by:
hi I have datalist control in my ASP.NET application the problem here is i have used a textbox with multiline true propertly when i enter data like "fdjsfhjksdhfjsdfhsdjhfsdfhsdjfhsd...
2
by: Carole MacDonald | last post by:
There have been lots of posts on this topic, but I haven't been able to apply any of the suggestions to my situation. I have an .aspx page with a form on it that has several submit buttons on...
5
by: Robert | last post by:
Hello Accessors I have some reports created in Access that are very good for what they do. However, it seems to me that when you are displaying information you don't need to print out that a...
5
by: Tomaz Koritnik | last post by:
Hi I have many short HTML files stored in a binary stream storage to display descriptions for various items in application. HTML would be display inside application using some .NET control or...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.