473,666 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Displaying message in c#

26 New Member
Hi, I am displaying message in c# like this

Response.Write( "<script>al ert( '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 1413
r035198x
13,262 MVP
Hi, I am displaying message in c# like this

Response.Write( "<script>al ert( '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 Recognized Expert Expert
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 Recognized Expert Contributor
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 Recognized Expert Expert
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 Recognized Expert Contributor
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
2785
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 macedonian input boxes so when you type into them, it is entered into macedonian font? I dont want the users to be downloading anything also. thanks,
1
2461
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 bottom of the example is displaying (I have others that don't), while the jpg file at the top isn't. Both files are in the same folder (visible bith physical in WE and virtual in CM) as the asp file itself. WHen not displaying, it displays instead...
8
5786
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 information from MEMO fields within the Access 2000 database. I have not had any problems before displaying MEMO fields on NT and have tried various tips to resolve this issue but no luck so far. I was wondering if anyone had come accross a similar...
2
2847
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 any html from the xml file as text, ie its displaying as text <br/> and <b> etc
1
2261
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 jfdsjfksdjfksdjkfjsdfjksdjfsdjfd fdsfhjsdhfjsdhfjf dsjf dsjfhjsdfhjksdh d fdsjf hsdjkfhdjsfhsdjfh ds
2
3439
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 it. Clicking a button will cause a web service action that returns XML. I would like to display this XML response on the page with the form. I know I can display XML in an IFRAME by pointing its source to an XML file. But I'm streaming the XML...
5
2217
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 printer-friendly report is not the best way to go. So, I tried converting one of my Access reports to an Access form. I selected the continuous view to allow displaying multple records but when I went to define my sorting and grouping there was none...
5
7839
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 COM control (like Microsoft WebBrowser). For each description there is one HTML file and along description text, it contains links to related information. Clicking related information would for example open new form in application and display some...
2
4332
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 displaying the contents of the data source, whilst another control updates the datasource via a command buttons implementation of 'Click', an event raised in the 'Handle Postback Events' stage of the control execution life cycle (via the...
7
6651
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 tabcontainer which has 1 panel already, however I want to try create the TabPanels dynamically. I followed the advice here: http://www.asp.net/learn/ajax-videos/video-156.aspx (3rd comment - Joe Stagner)
0
8348
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8863
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1761
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.