Than Aung
I want to do this....not sure if I can
I can get the Alert and the value from "script" below (In the TrEdit.aspx.cs FILE seen below)
I would like to take that and pass it to an external Javascript function defined in the aspx page
Maybe this is whats causing my error below?
Maybe I cannot do this entirely?
<script lang="javascript" src = "js/index.js" type="text/javascript"></script>
ERROR:
VM187:1 Uncaught ReferenceError: myFunctionCSharp is not defined
at <anonymous>:1:13
Site.Master -- Notice context to MainContent referencing the second ASPX page below
The JS page is defined here on the Site.Master file....
<link rel="stylesheet" href="https://js.arcgis.com/4.14/esri/themes/light/main.css"/>
<script src="https://js.arcgis.com/4.14/"></script>
<script lang="javascript" src = "js/index.js" type="text/javascript"></script>
</head>
<body class="home">
<main>
<br />
<br />
<article>
<form id="form1" runat="server">
<div id="content">
<h1>List</h1>
<h2 id="tagline"><i><%: Page.Title %></i></h2>
<asp:ContentPlaceHolder ID="MainContent" runat="server"></asp:ContentPlaceHolder>
</div>
</form>
</article>
</main>
</body>
</html>
TrEdit.aspx file - Notice the reference to the .aspx.cs page below
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="TrEdit.aspx.cs" Inherits="NW.Edit" MaintainScrollPositionOnPostback="true" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
TrEdit.aspx.cs FILE
I am trying to call the JavaScript function from here BECAUSE I cannot do it on the page load complete as I am not being sent to another page...I want to fire the JS code from this function
I AM RUNNING the below code in the protected void from xxxx.aspx which is referenced in the Site.Master file... ID="MainContent"
protected void gvTrappers_SelectedIndexChanged(object sender, EventArgs e)
{
int i;
if (row != null)
{
i = row.RowIndex; ;
}
else
{
btnExpandCritters_Click(sender, e);
}
string IDGUID = Session["NWTL_ID_String"].ToString();
string IDGUIDstring = IDGUID;
string nIDGUID11 = "alert(\"" + IDGUIDstring + "\")";
string script = nIDGUID11;
ScriptManager.RegisterStartupScript(this, GetType(),"ServerControlScript", script, true);
ScriptManager.RegisterStartupScript(this, GetType(), "Javascript", "javascript: myFunctionCSharp(IDGUID);", true);
}
In the EXTERNAL JS PAGE
require([
"esri/Map", "esri/views/MapView", "esri/layers/FeatureLayer"
], function (Map, MapView, FeatureLayer
) {
"use strict";
function myFunctionCSharp(input) {
var inputValue = input;
alert(inputValue);
}