Results 1 to 8 of 8

Thread: Setting the text of a button once the server side routine is finished.

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    Setting the text of a button once the server side routine is finished.

    Hi,

    I have a button (Export) which when click on calls a server side routine. The server side routine runs through several database tables to some work. Once the routine has finished I want to change the text to (Exit).

    I've tried this server side but it is not getting fired:-

    ScriptManager.RegisterStartupScript(Me, Page.GetType, "ChangeText", "ChangeLabel", True)

    And this is the javascript:-

    <body>
    <script type="text/javascript">
    function ChangeLabel() {
    var ExportButton = document.getElementById('butExport');
    ExportButton.value('Exit');
    }
    </script>

    Thanks for any advice,

    Jiggy

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,605

    Re: Setting the text of a button once the server side routine is finished.

    I think ScriptManager.RegisterStartupScript will only play on page loading but a very easy workaround would be to call a web service to do the job and on "success" to change the text, the button would be html one.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    Re: Setting the text of a button once the server side routine is finished.

    Quote Originally Posted by sapator View Post
    I think ScriptManager.RegisterStartupScript will only play on page loading but a very easy workaround would be to call a web service to do the job and on "success" to change the text, the button would be html one.
    Thanks for that; my problem is there is a load more sub routines doing different things and I always run into restrictions in web services.

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,605

    Re: Setting the text of a button once the server side routine is finished.

    You said that "The server side routine runs through several database tables to some work".
    This can be done in a web service or WCF or WEB API without practically changing a thing (maybe pass the ID or some value and that can be done by passing it into the web service).
    A question i have here is that your button is probably a server side one, else it would not trigger the routines.
    So can't you simple do butExport.text = "something" at the end of the server call?
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    Re: Setting the text of a button once the server side routine is finished.

    Quote Originally Posted by sapator View Post
    You said that "The server side routine runs through several database tables to some work".
    This can be done in a web service or WCF or WEB API without practically changing a thing (maybe pass the ID or some value and that can be done by passing it into the web service).
    A question i have here is that your button is probably a server side one, else it would not trigger the routines.
    So can't you simple do butExport.text = "something" at the end of the server call?
    Sorry I only mention doing something with tablets to make it brief. The actual routine is creating a memory table, putting data into it, add photos, and working with crystal reports to output as a PDF. I did what you said at the end of the routine but the user has to click the export button first. So I think what is happening is the page is already fully rendered then when they click the export button it does not re-render the page so doing the butExport.Text = " ddddd" won't work. Ideally I wanted to execute my code on the load but it does not show my div's etc until the routine was finished.

    Thanks for the help.

  6. #6
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,605

    Re: Setting the text of a button once the server side routine is finished.

    Does not matter, you can do these in a web service.
    So anyhow, let me get this straight. You FIRST click the button and then the routines run and do all these, right?
    Else you would just change the button name on page load.
    If you click the button i don't see a reason why it could not change text, unless you don't catch the ispostback of the page, i would try but currently my work VS evalution period has expired and we cannot seem to be able to log in to Microsoft today, thus loosing money. So i guess Bill Gates will write us a check for the time and money we are loosing, not able to log in and register Visual studio (?).
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,806

    Re: Setting the text of a button once the server side routine is finished.

    Quote Originally Posted by sapator View Post
    Does not matter, you can do these in a web service.
    So anyhow, let me get this straight. You FIRST click the button and then the routines run and do all these, right?
    Else you would just change the button name on page load.
    If you click the button i don't see a reason why it could not change text, unless you don't catch the ispostback of the page, i would try but currently my work VS evalution period has expired and we cannot seem to be able to log in to Microsoft today, thus loosing money. So i guess Bill Gates will write us a check for the time and money we are loosing, not able to log in and register Visual studio (?).
    Hi Sapator,

    Yes when you click the button it runs the routine. Something that maybe causing the problem is at the end I call this code which saves the zip file created:-

    Response.Clear()
    Response.BufferOutput = False
    HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" & Session("SiteName") & "-CICs.zip")
    HttpContext.Current.Response.ContentType = "application/zip"

    Using zip As New ZipFile
    Dim pdfFiles = IO.Directory.GetFiles(sdestPath, "*.pdf")
    For Each filenm As String In pdfFiles
    zip.AddFile(filenm, "Files")
    Next
    zip.Save(Response.OutputStream)
    End Using
    Response.[End]()
    butExport.Text = "Click To Exit"

    Thanks again for your help,

    Jiggy

  8. #8
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,605

    Re: Setting the text of a button once the server side routine is finished.

    I'm not sure if that will mess with the button but why don't you try putting the button text code up to the very first line of the routine. The server will not post the text until everything is loaded anyhow. And try removing that code to see if it makes a difference.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width