S
SteveS
Hello. This problem is perplexing me.
I have a asp:button which runs a javascript function when it is clicked. It
returns a true or false depending if a postback is needed. This works great
when I run it on my development pc. But, when I run it from another
computer, it ALWAYS does a postback, even if it returns false. I have no
ideas why????
The plot thickens... I don't know if this really matters or not, but this
button is in a datagrid.
Can anyone explain to me why the javascript function posts back????? The
code is posted below.
Thank you in advance!
SteveS
******ASPX CODE************
<asp
atagirid......>
..
<asp:TemplateColumn HeaderText="Deny" ItemStyle-HorizontalAlign=Center
HeaderStyle-HorizontalAlign=Center>
<ItemTemplate>
<asp:Button text="Deny" ID="btnDeny" Runat="server"
CommandName="btnDeny"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
..
</asp
atagrid>
<script lang=javascript>
function OpenDenyWindow(changeId, btn) {
var ret = false
retVal=window.showModalDialog('DenialEmailForm.aspx?id=' +
changeId+'&mem='+document.Form1.hdnMemId.value,'', '');
alert ("retval = " + retVal)
if (retVal == "Successful") {
//return true
ret = true
}
else {
//return false
ret = false
}
alert(ret);
// *** even if this function returns a FALSE, the form is still posted
when I am not running the web page from my local host.
return ret;
}
**** CODE BEHIND****
Private Sub grdList_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdList.ItemCreated
'ADD THE JAVASCRIPT TO TO THE BUTTON
Dim ctrlDeny As Button = CType(e.Item.FindControl("btnDeny"),
Button)
If Not IsNothing(ctrlDeny) Then
Dim grid As DataGrid = CType(sender, DataGrid)
ctrlDeny.Attributes.Add("onclick", "return OpenDenyWindow("
& grid.DataKeys(e.Item.ItemIndex).ToString & ", this); return false;")
End If
End Sub
I have a asp:button which runs a javascript function when it is clicked. It
returns a true or false depending if a postback is needed. This works great
when I run it on my development pc. But, when I run it from another
computer, it ALWAYS does a postback, even if it returns false. I have no
ideas why????
The plot thickens... I don't know if this really matters or not, but this
button is in a datagrid.
Can anyone explain to me why the javascript function posts back????? The
code is posted below.
Thank you in advance!
SteveS
******ASPX CODE************
<asp

..
<asp:TemplateColumn HeaderText="Deny" ItemStyle-HorizontalAlign=Center
HeaderStyle-HorizontalAlign=Center>
<ItemTemplate>
<asp:Button text="Deny" ID="btnDeny" Runat="server"
CommandName="btnDeny"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
..
</asp

<script lang=javascript>
function OpenDenyWindow(changeId, btn) {
var ret = false
retVal=window.showModalDialog('DenialEmailForm.aspx?id=' +
changeId+'&mem='+document.Form1.hdnMemId.value,'', '');
alert ("retval = " + retVal)
if (retVal == "Successful") {
//return true
ret = true
}
else {
//return false
ret = false
}
alert(ret);
// *** even if this function returns a FALSE, the form is still posted
when I am not running the web page from my local host.
return ret;
}
**** CODE BEHIND****
Private Sub grdList_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdList.ItemCreated
'ADD THE JAVASCRIPT TO TO THE BUTTON
Dim ctrlDeny As Button = CType(e.Item.FindControl("btnDeny"),
Button)
If Not IsNothing(ctrlDeny) Then
Dim grid As DataGrid = CType(sender, DataGrid)
ctrlDeny.Attributes.Add("onclick", "return OpenDenyWindow("
& grid.DataKeys(e.Item.ItemIndex).ToString & ", this); return false;")
End If
End Sub