Link to home
Start Free TrialLog in
Avatar of thenthorn1010
thenthorn1010Flag for United States of America

asked on

How to Pass a Variable to a Pop Up Box in C#/JavaScript/ASP .NET From C#

I am attempting to modify a web page that requires a string to be passed to it based on information that is retrieved from a database query within the C# portion of the web site coding. I was wondering if someone could tell me how I would pass or retrieve a variable inside of the ASP .NET file from the C# application. In other words, let's say I wanted to display the string variable results on the aspx page. How would I get the value of results from the C# page over to the ASP .NET page to be displayed in the JavaScript error message <script type = "text/javascript"> alert(<DIsplay the contents of the results variable from the C# page>)</script>

Any help that you could provide would be greatly appreciated.
Avatar of TonyReba
TonyReba
Flag of United States of America image

Something like this should work
<script type="text/javascript" language="javascript">         function funDoSomething()     {         var strMessage = <%= "'" + str + "'"%>;         alert( strMessage );     }  </script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Bardobrave
Bardobrave
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What was wrong with my answer , did you try it?