Solved

timer redirect to hta from asp.net page

Posted on 2014-02-20
16
575 Views
Last Modified: 2014-03-14
Hello,
I have the following:
ajax update panel. Inside it, there is an ajax timer.

In the Timer_tick there is a Response.Redirect("MyPage.hta")

The problem is that the timer fires only once. After the first response.redirect("MyPage.hta") no more Tick is fired.

The hta page is needed to run an exe file.

What am I doing wrong? Is there another way to do it?


Here my code:

<asp:UpdatePanel ID="updQuality" runat="server">
                        <Triggers>
                          <asp:AsyncPostBackTrigger ControlID="TimerQuality" EventName="Tick" />
                             </Triggers>
                             <ContentTemplate>
                                 <asp:Timer ID="TimerQuality" runat="server" ClientIDMode="Static" Interval="10000"  />

                                      <div>
                                         <asp:CheckBox ID="chkManageQualityAutomatic" runat="server"  Text="<%$ Resources:Dictionary, LABEL_10496%>" AutoPostBack="True" CssClass="chkManageQualityAutomatic" />
                                      </div>
                                      <div>
                                          <asp:Label ID="lblTime" runat="server" Text=""></asp:Label>
                                      </div>
                         
                                             
                             </ContentTemplate>
                         </asp:UpdatePanel>




        Protected Sub TimerQuality_Tick(sender As Object, e As System.EventArgs) Handles TimerQuality.Tick

               response.redirect("MyFile.hta")


        End Sub
0
Comment
Question by:ErikIce
  • 8
  • 7
16 Comments
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39876177
seems like double handling to run an hta to execute an exe. Can you use the shell to run your exe as i think using response.redirect is causing an issue for you as it may not return a value to the update panel
0
 

Author Comment

by:ErikIce
ID: 39876277
Hi,
thaks for reply.
What do you mean as "double handing"?
And how can I use the shell to run an exe from browser?

Thanks
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39876355
Sorry, does the exe need to run locally or on the server? If locally then the hta is applicable otherwise the server can run it
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:ErikIce
ID: 39876359
the exe has to run rocally. think for example that hta has to open notepad.exe ..
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39876401
Ok that makes sense. Something isn't sitting right about this though and i can't out finger on it but I'll let you know if I think of it

You can confirm that the hta runs at least once right?

You're telling an AJAX response to redirect, which i think is where your issue lies. Does this need to be within an update panel?
0
 

Author Comment

by:ErikIce
ID: 39876695
yes, hts runs at least once.
No... I think that update panel is not needed, may be. I don't know if timer needs it.
Thanks
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39878929
The timer doesn't have to be in an update panel, it will just trigger it to update if configured as such.  Outside the update panel it just becomes a trigger you can do whatever you like with.  I would suggest something more like a hidden iframe that points to the hta.
When your trigger goes off it will just refresh the iframe.
0
 

Accepted Solution

by:
ErikIce earned 0 total points
ID: 39881951
Hi,
I've found out the solution. No way using response.redirect.
I've solved it in the following way:
1. I've put the timer outside the panel.

            <asp:Timer ID="TimerQuality" runat="server" ClientIDMode="Static" Interval="10000"  />
                         <asp:UpdatePanel ID="updQuality" runat="server">
                         <Triggers>
                                      <asp:AsyncPostBackTrigger ControlID="TimerQuality" EventName="Tick" />
                             </Triggers>
                             <ContentTemplate>
                                 
                                 <div class="pnlQualityInt">
                                     <div>
                                     <asp:Label ID="lblQuality" runat="server" Text="<%$ Resources:Dictionary, LABEL_10495 %>" CssClass="lblQuality"></asp:Label>
                                     </div>
                                      <div>
                                         <asp:CheckBox ID="chkManageQualityAutomatic" runat="server"  Text="<%$ Resources:Dictionary, LABEL_10496%>" AutoPostBack="True" CssClass="chkManageQualityAutomatic" />
                                      </div>
                                      <div>
                                          <asp:Label ID="lblTime" runat="server" Text=""></asp:Label>
                                      </div>
                                 </div>
                                             
                        '...here I have more controls....            

                             </ContentTemplate>
                         </asp:UpdatePanel>

2. In the Timer_Tick:

           Dim _command As String

            _command = "QualityControl('Logistic.hta?COMMAND=C:\MY_BAT.BAT')"

            ScriptManager.RegisterStartupScript(Me, Me.GetType(), "", _command, True)

3. The QualityControl javascript function is:

<script id="Script1" type="text/javascript">

<!--

    function QualityControl(keyValue) {

        if (keyValue != null) {
            var win = window.open(keyValue, '_blank');

            win.focus();

        }
    }
    //END OPEN QUALITY CONTROL
// -->

</script>
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39881996
Excellent. Glad we got there in the end :-)
0
 

Author Comment

by:ErikIce
ID: 39928820
I've requested that this question be closed as follows:

Accepted answer: 0 points for ErikIce's comment #a39881951

for the following reason:

works..
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39928821
see http:#a39878929.

The timer doesn't have to be in an update panel, it will just trigger it to update if configured as such.  Outside the update panel it just becomes a trigger you can do whatever you like with.
0
 

Author Comment

by:ErikIce
ID: 39928841
Hello, I'm very sorry, how can I mark MY POST as accepted solution?
I've found it by myself.. ... why does it is not Accepted Answer????
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39928845
You did that's why I objected.  I said to move the time outside the panel and then use it as a trigger to run your hta.  How is that not helping you get your answer?
0
 

Assisted Solution

by:ErikIce
ErikIce earned 0 total points
ID: 39928889
It works even if timer is inside the panel. The problem was not there, the problem was that  the response.redirect disables the timer , don't know why.
The solution was to register a script clientside
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39928900
Ok my bad. I'll start the close process again but thanks for clarifying
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question