?
Solved

timer redirect to hta from asp.net page

Posted on 2014-02-20
16
Medium Priority
?
602 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
16 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
Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

801 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