Howdy Tom!
I haven't created all the code for you, just the concept of how to create
the cycle of JavaScript calls CodeBehind and CodeBehind calls JavaScript
Back.
Hope it helps!
William
Default.aspx:
Code View:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<html xmlns="
http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<a href="javascript:LinkButton1.click();">Click to Cause Postback</a>
<div style="display: none;">
<asp:UpdatePanel ID="upnl_Main" runat="server"
ChildrenAsTriggers="false" UpdateMode="conditional">
<ContentTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" Text="" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Code Behind:
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles LinkButton1.Click
'Do your lookups, checking and validation here.
Dim ScriptBuilder As New StringBuilder
'Build custom Javascript depending on your results.
ScriptBuilder.Append("function MyScript() {" + Environment.NewLine)
ScriptBuilder.Append(" alert('Howdy, I am dynamically created
javascript.');" + Environment.NewLine)
ScriptBuilder.Append("}" + Environment.NewLine)
ScriptBuilder.Append("MyScript();" + Environment.NewLine)
'register the javascript to the update panel control and update that
panel.
ScriptManager.RegisterStartupScript(upnl_Main, upnl_Main.GetType(),
"MyScript", ScriptBuilder.ToString, True)
upnl_Main.Update()
End Sub
End Class