Cheers for the replies.
Right...OK. Bit of a cheap hack/frig don't you think?
How about...
Code to create JS:
VB Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
doPostBack(Me)
End Sub
Private Sub doPostBack(ByVal oPage As Page)
If oPage.IsClientScriptBlockRegistered("__doPostBack") Then Return
oPage.RegisterClientScriptBlock("__doPostBack", GetPostBackScript)
oPage.RegisterHiddenField("__EVENTTARGET", "")
oPage.RegisterHiddenField("__EVENTARGUMENT", "")
End Sub
Private Function GetPostBackScript() As String
Dim Java As New StringBuilder(1024)
With Java
.Append("function __doPostBack(eventTarget, eventArgument) " + nl)
.Append("{ " + nl)
.Append(" var theform; " + nl)
.Append(" " + nl)
.Append(" if (window.navigator.appName.toLowerCase().indexOf('microsoft') > -1) " + nl)
.Append(" { " + nl)
.Append(" theform = document.Form1; " + nl)
.Append(" } " + nl)
.Append(" else " + nl)
.Append(" { " + nl)
.Append(" theform = document.forms['Form1']; " + nl)
.Append(" } " + nl)
.Append(" " + nl)
.Append(" theform.__EVENTTARGET.value = eventTarget.split('$').join(':'); " + nl)
.Append(" theform.__EVENTARGUMENT.value = eventArgument;theform.submit(); " + nl)
End With
Return Java.ToString
End Function
Now you need a hidden control in your page to handle the postback and store some data:
Code:
<input type="hidden" id="VisitorKeys" value="" runat=server NAME="VisitorKeys">
And now the JS function that is called from a button click event or something:
Code:
function SelectedVisitors(VisitorKeyValues)
{
document.forms[0].VisitorKeys.value=VisitorKeyValues
__doPostBack(document.forms[0].VisitorKeys.value, '')
}
We now need a function in the code behind to handle this postback.
because we are using a hidden input control we can use an event of this:
VB Code:
Private Sub VisitorKeys_ServerChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles VisitorKeys.ServerChange
Dim Keys As String = VisitorKeys.Value
'Handle code here
End Sub
make sense?
Woka