Solved

timer redirect to hta from asp.net page

Posted on 2014-02-20
16
567 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
 

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now