Term56
asked on
need help disabling a client side button before the server side fires
I have an app that takes variables, passes them to a crystal report, and then exports the end result to a pdf.
I was curious if anyone could tell me if there was a way to fire the server side, but disable a button, or say it is processing on the client side before the server side actually fires.
<asp:button id="Button1" runat="server" Text="Export To PDF"></asp:button>
this is the button. Problem is, if I try to disable the button server side, it doesnt refresh until it already delivers the pdf.
I am assuming I need to use clientside, but dont know how to using javascript. I dont know if it is possible, but perhaps have javascript that disables the button, and somehow causes a postback, but I need
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Bind_Data()
End Sub
server side to fire.
I was curious if anyone could tell me if there was a way to fire the server side, but disable a button, or say it is processing on the client side before the server side actually fires.
<asp:button id="Button1" runat="server" Text="Export To PDF"></asp:button>
this is the button. Problem is, if I try to disable the button server side, it doesnt refresh until it already delivers the pdf.
I am assuming I need to use clientside, but dont know how to using javascript. I dont know if it is possible, but perhaps have javascript that disables the button, and somehow causes a postback, but I need
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Bind_Data()
End Sub
server side to fire.
ASKER
I'll try it when I get to work. actually it is .net 1.1. but you are basically correct, I need some way to cause a client side effect before the post, as it can take 30-45 seconds to generate the report(lots of data is being parsed in the crystal report).
If you're using the 1.1 Framework, you won't find a ClientScript object. Instead:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim js As String = "document.forms[0].myButto n.enabled = false;"
RegisterClientScriptBlock( "myFunctio n", js)
Bind_Data()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim js As String = "document.forms[0].myButto
RegisterClientScriptBlock(
Bind_Data()
End Sub
ASKER
tried using mybutton and button1 and neither work.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim js As String = "document.forms[0].button1 .enabled = false;"
RegisterClientScriptBlock( "myFunctio n", js)
Bind_Data()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim js As String = "document.forms[0].button1
RegisterClientScriptBlock(
Bind_Data()
End Sub
If your button is set to submit, that will be an issue. I also forgot to add the tags to the script. In 2.0, a boolean arg outputs them for you. In < 2.0, you have to insert them yourself.
<asp:Button ID="myButton" runat="server" Text="Export To PDF" />
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles myButton.Click
Dim js As String = "<script language=javascript>docume nt.forms[0 ].myButton .enabled = false;</script>"
RegisterClientScriptBlock( "disabler" , js)
Bind_Data()
End Sub
<asp:Button ID="myButton" runat="server" Text="Export To PDF" />
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles myButton.Click
Dim js As String = "<script language=javascript>docume
RegisterClientScriptBlock(
Bind_Data()
End Sub
ASKER
nope, still not working.
yeah, unfortunately it is a submit, i knew i'd run into trouble.
yeah, unfortunately it is a submit, i knew i'd run into trouble.
Can you post a bit more of your page behind code please?
ASKER
sure
this is the Bind_data()
Private Sub Bind_Data()
Dim strtest As New WEBTr_Full_Day_Report_v15
Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table
Dim TableCounter
'Passes LogOn information to the report.
With crConnectionInfo
.ServerName = "FMSATURN"
.DatabaseName = "BILLINGS"
.UserID = ""
.Password = ""
End With
CrTables = strtest.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.Connectio nInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crt ableLogoni nfo)
Next
'Sets the parameters
If txtStart.Text <> "" Then
strtest.SetParameterValue( "@StartDat e", txtStart.Text)
Else
strtest.SetParameterValue( "@StartDat e", " ")
End If
If txtEnd.Text <> "" Then
strtest.SetParameterValue( "@EndDate" , txtEnd.Text)
Else
strtest.SetParameterValue( "@EndDate" , " ")
End If
strtest.SetParameterValue( "@Resource s", GetResources)
strtest.SetParameterValue( "@ResDept" , GetDepartments)
strtest.SetParameterValue( "@MyFlag", ddFlag.SelectedValue)
Dim oStream As New MemoryStream ' // using System.IO
oStream = strtest.ExportToStream(Exp ortFormatT ype.Portab leDocForma t)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/pdf"
Response.BinaryWrite(oStre am.ToArray ())
Response.End()
End Sub
this is the Bind_data()
Private Sub Bind_Data()
Dim strtest As New WEBTr_Full_Day_Report_v15
Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table
Dim TableCounter
'Passes LogOn information to the report.
With crConnectionInfo
.ServerName = "FMSATURN"
.DatabaseName = "BILLINGS"
.UserID = ""
.Password = ""
End With
CrTables = strtest.Database.Tables
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.Connectio
CrTable.ApplyLogOnInfo(crt
Next
'Sets the parameters
If txtStart.Text <> "" Then
strtest.SetParameterValue(
Else
strtest.SetParameterValue(
End If
If txtEnd.Text <> "" Then
strtest.SetParameterValue(
Else
strtest.SetParameterValue(
End If
strtest.SetParameterValue(
strtest.SetParameterValue(
strtest.SetParameterValue(
Dim oStream As New MemoryStream ' // using System.IO
oStream = strtest.ExportToStream(Exp
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/pdf"
Response.BinaryWrite(oStre
Response.End()
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The only way to properly answer the question is with enough relevant information. I have taken a few runs at it, but if the suggestions above have not worked, we would need to see or understand more of the source code to give a solution.
ASKER
ok bglodde, I do appreciate all the effort you put into it. Let me post as much code as possible relevant to it
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim js As String = "document.forms[0].myButto
ClientScript.RegisterClien
Bind_Data()
End Sub