My website is on WPF project. I want to pass a string from my cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
public string strHello = "Hello World!";
protected void Page_Load(object sender, EventArgs e)
{
}
}
To my website:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<script type="text/javascript">var jsstrHW = '<%=strHW%>'; alert("jsstrHW = " + jsstrHW);</script>
</head>
<body>
</body>
</html>
The output from alert method:
jsstrHW = <%=strHW%>
Please guide me how to do it right. Thanks a lot, Orian.
EDIT: I tried:
ScriptManager.RegisterStartupScript(this, this.GetType(), "someID", "alert('This pops up');", true);
and it didn't work as well. I copied only my aspx file and his cs file to other folder, then I closed my solution and created new one with those files. Everything worked on Google Chrome! So.. my code is probably right, but something in my solution ruin my website. what can it be? As I said before - I need that website for WPF app and not for Google Chrome (or Mozilla Firefox, etc.).
Thanks again, Orian.