?
Solved

timer redirect to hta from asp.net page

Posted on 2014-02-20
16
Medium Priority
?
611 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
15 Comments
 
LVL 43

Expert Comment

by:Rob
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 43

Expert Comment

by:Rob
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
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 

Author Comment

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

Expert Comment

by:Rob
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 43

Expert Comment

by:Rob
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 43

Expert Comment

by:Rob
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 43

Expert Comment

by:Rob
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 43

Expert Comment

by:Rob
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 43

Expert Comment

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

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

839 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