Category Archives: Timer

Timer

[RESOLVED]New to Ajax – my first Test Form not behaving as expected

Hello - 

I’m new to AJAX and going through an example in a book. It’s a very simple exercise which I was hoping to evolve into something real-world. 

Problem is my panel know as pnlConfirmation is not being displayed once the timer runs out.  When I click the button and fire the event, the UpdateProgress panel does show as expected but once it’s done, pnlConfirmation is not displayed.
 I was hoping for a second set of eyes to point of the obvious error.  Thanks!!

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Panel ID="pnlForm" runat="server"> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Do something awesome" OnClick="Button1_Click" /> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"> <ProgressTemplate> <asp:Panel ID="pnlProgress" runat="server"> <br /><br /> Doing something awesome now..... <br /><br /> </asp:Panel> </ProgressTemplate> </asp:UpdateProgress> <asp:Panel ID="pnlConfirmation" runat="server" Visible="False"> <br /><br /> Something awesome was done. <br /><br /> </asp:Panel>

…and…the button’s click event (C#):

    protected void Button1_Click(object sender, EventArgs e)
    {
        
        pnlConfirmation.Visible = true;
        pnlForm.Visible = false;
        System.Threading.Thread.Sleep(5000);

    }


What am I doing wrong?

The panel needs to be inside the updatepanel contenttemplate. 

Thanks but that didn’t seem to make a difference.  Like this?

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Panel ID="pnlForm" runat="server">
            <br /><br />
            <asp:Button ID="Button1" runat="server" Text="Do something awesome" OnClick="Button1_Click" />
            </asp:Panel>

             <asp:Panel ID="Panel1" runat="server" Visible="False">
                <br /><br />
                 Something awesome was done.
                <br /><br />
             </asp:Panel>

        </ContentTemplate>
    </asp:UpdatePanel>


    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
            <asp:Panel ID="pnlProgress" runat="server">
            <br /><br />
            Doing something awesome now.....
            <br /><br />
            </asp:Panel>
        </ProgressTemplate>
    </asp:UpdateProgress>

You now have Panel1; this was pnlConfirmation.

<facepalm />

Thanks!

Unable to fire a click event using link button in repeater

Hi, 

I am using the Modal popup controler for showing the notification of new message by using Panel control . In that panel control i am using a repeater .

In repeater i have lable and link button . After i show the notification message using linkbutton the unread message will become read . But in that i am unable to fire the click event in

the linkbutton.

my code is : 

front end code:-

<asp:Panel ID="Panel3" runat="server" BackColor="white" style="display:none" BorderWidth="1" Width="500px" Height="200px" BorderColor="#108EBF">
<center>
<div class=" col-sm-5 ">

<asp:Repeater ID="rptnewmsg" runat="server" OnItemCommand="lnkmsgstatus_Command" >

<ItemTemplate>
<div style=" width:300px; height:150px; border:solid 0px red;">

<a style=" color:Black;"> File received from </a> <asp:Label ID="lblclientnamessTF" runat="server" Text=’<%#Eval("Clientname") %>’></asp:Label> <a style=" color:Black;"> for </a> <asp:Label ID="Label2" runat="server" Text=’<%#Eval("Boardtype") %>’></asp:Label>
<br />

<asp:LinkButton ID="lnkmsgstatus" runat="server" CommandArgument=’<%Eval("Id") %>’ CommandName="Unread" OnCommand="lnkmsgstatus_Command" Text="Unread" ></asp:LinkButton><br /><br />

</div>

</ItemTemplate>

</asp:Repeater>

<button id="btncancelss" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<div class="modal-body" style=" margin-top:50px;">

<%–
<div class="well">

<div class="form-group">

<h4 class=" col-sm-offset-5 " style=" color:Black; " >Post Comments</h4>

<label for="name">Comments</label><br /> <asp:TextBox ID="TextBox1" runat="server" CssClass=" form-control"></asp:TextBox><br /><br />

</div>

</div>–%>
</div>

</div>

</center>
</asp:Panel>

<asp:ModalPopupExtender ID="ModalPopupExtender3" BehaviorID="ModalPopupExtender3" runat="server" Enabled="true" PopupControlID="Panel3" TargetControlID="Panel3" CancelControlID="btncancelss" OnCancelScript="hidepopupss()" BackgroundCssClass="modalback">
</asp:ModalPopupExtender>

c# code :-

protected void lnkmsgstatus_Click(object sender, EventArgs e)
{
string lnkbtnmsg = (sender as LinkButton).CommandArgument;
con.Open();

SqlCommand cmdupdatemsg = new SqlCommand("update Newmessage set Readstatus =’" + 1 + "’ where Id = ‘" + lnkbtnmsg + "’", con);
cmdupdatemsg.ExecuteNonQuery();

con.Close();

}

protected void Timer1_Tick(object sender, EventArgs e)
{

Newmsgbind();
ModalPopupExtender3.Show();

}

public void Newmsgbind()
{
SqlDataAdapter da_newmsg = new SqlDataAdapter("select Id,Clientname,Boardtype ,Date from Newmessage where Readstatus =’" + 0 + "’", con);
DataSet ds_newmsg = new DataSet();
da_newmsg.Fill(ds_newmsg);

rptnewmsg.DataSource = ds_newmsg;
rptnewmsg.DataBind();
}

Hi a.arunan,

Thanks for your post.

Firstly, you should implement Repeater.ItemCommand Event, this Event occurs when a button is clicked in the Repeater control.

Secondly, you should modify your code as below.

protected void lnkmsgstatus_Command(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName=="Unread")
            {
                //do some operations when click linkbutton

                string str = e.CommandArgument.ToString();
                con.Open();

                SqlCommand cmdupdatemsg = new SqlCommand("update Newmessage set Readstatus ='" + 1 + "' where Id = '" + lnkbtnmsg + "'", con);
                cmdupdatemsg.ExecuteNonQuery();

                con.Close();

            }
        }  

For more information about Repeater.ItemCommand Event, you could refer to the following link.

If you have any question about my reply, please let me know freely.

Best Regards,

Fei Han

Dear Fei Han,

Its not working

For some reason when you set a button as the TargetControlID of the modal popup ,it disables the Click event.

I suggest that you can set a hidden field first, then set the id  as the targetcontrolid for modal popup.

then  in the click event ,you can show the modal popup.

[RESOLVED]Ajax page – Timer.cshtml – where do I look to solve this.

I am re-running through the examples in my webmatrix books – and having a perplexing problem.   I have a page, called Timer.cshtml -which I copied from the example in the books download code – and when I run in from the example code, the time clock ticks
second by second nicely – I copy that same page into my starter site app, as well as the jquery-1.6.2.min.js file into the /scripts folder and it doesnt work.  So the same page – linked to only that one .js file – works in the example folder – but not in my
startersite folder.  I need Ajax in an app I am writing and I need this example to work  - what would be the most obvious mistake I could make to screw this up.  and the folder and the name of the .js file are perfect, I copied and pasted them to be sure.
 Thanks in advance.

DonnieS

Since that code works than there is an error with your own StarterSite project. I believe there is some other JavaScript code or library required for it. 

Would you mind sharing minimum code to work on, the buggy code you’re having etc? 

The one thing that you can do to understand the trouble would be to open the Developer Tools in your browser, press F12 and go to the Console, Console would let you know what is missing that was required. It would give you the errors that are causing troubles
in your project. You can yourself manage this project by using the Console errors and Googling them, or try to provide a fiddle for that. 

Thank you so much Ahmad,  I had forgotten about using F12 – it tells me that it cant find GetTime in the StarterSite project – but it can in the identical timer.cshtml over in the example code – this is from Mike’s book btw.  I have this to reference the
.js file - 

 <script src="~/Scripts/jquery-1.8.2.min.js"></script>

The line below is the line from the example code – I have tried it , but it doesnt work in the StarterSite Project – the example code is Chapter6 of Mike’s book, which like I said , works fine.  So i am using F12 to chase this down – though havent
got it yet.

 <script src="@Href("~/Scripts/jquery-1.8.2.min.js")" type="text/javascript"></script>

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:17711/GetTime/?_=1411301258005
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:17711/GetTime/?_=1411301259006
GET http://localhost:17711/GetTime/?_=1411301260007 404 (Not Found) jquery-1.8.2.min.js:2
GET http://localhost:17711/GetTime/?_=1411301261007 404 (Not Found)

The error messages tell you that the files are not file. GetTime file at the root location, isn’t found. I really believe you’re missing the reference, or the file itself. I believe there would be some
Read this kind of thing on the page if this is the exact copy of that code. 

However you can make sure that all the files are present at the same location they must be. Specially that GetTime file and the JavaScript resources.

getTime is in the -> 

 <script src="@Href("~/Scripts/jquery-1.8.2.min.js")" type="text/javascript"></script>

and this file is in the Scripts folder.

Well in that case, you can click on the line that represents the error on the right side where you’re seeing the error in the Console. It will take you to the line in the file where the error is with a little information too. 

Secondly, why don’t you download a new version of the file. It might have been damaged.

The download is new – I have used an old one too – and I switch to the cdn of the jquery file just to make sure.

DonnieS

getTime is in the -> 

 <script src="@Href("~/Scripts/jquery-1.8.2.min.js")" type="text/javascript"></script>

and this file is in the Scripts folder.

I don’t understand. Are you saying that gettime is in the scripts folder? If so, move it to the root folder of the site.

GetTime is in jquery-1.8.2.min.js,  its a function in that javascript file – checked capitalization, everything.  What I cant understand is why it works in the Chapter6 folder from your book – but when I copy that page into an empty, or startersite or my
working app – it does not work.  I moved the particular .js file – its in the /Scripts folder of course, like the example said to do – but I moved the jquery-1.8.2.min.js file from the site I am working on – over to the chapter6 folder – and it still works
there – just not in anything I touched.  Starting to think i have an hex on me (lol).    

DonnieS

Gettime is not a function in the jQuery file in my book. I would never add anything to the jQuery file. GetTime is a Razor .cshtml file. All it contains is one line of code:

@DateTime.Now

This file goes into the root of your site.

Holy jeez – I am so sorry for bothering you and Ahmad.  I see the file – I thought it was a function inside the jquery file.

Thank you guys – thank you.

DonnieS

[RESOLVED]Drop down does not postback within form

Hello i have a little problem on Form
Dropdownlist doesn’t postback the page..

i am using web form using masterpage

 my index.master is like this 

<form id="form1" action="" runat="server" >


<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                        
                    </asp:ContentPlaceHolder>
                        </form>

Here is my  selected registerdetail.aspx page

 Your Address</h3>
        <div class="registerbox">
            <fieldset>
                
                
                
                
                <div class="control-group">
                    <label class="control-label">
                        <span class="red">*</span>Country:</label> <asp:DropDownList ID="dropCountry" BackColor=White CssClass="libox" runat="server" OnSelectedIndexChanged="dropCountry_SelectedIndexChanged" AutoPostBack="True">
                        </asp:DropDownList>
                         
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="dropCountry" ErrorMessage="RequiredFieldValidator" ValidationGroup="ValidRegDetail"></asp:RequiredFieldValidator>
                   </div>
                 
                       <div class="controls">
&nbsp;<asp:Button ID="Button1" runat="server" OnClick="Button1_Click1" Text="Button" />
                           </div>
                </div>
                
                <div class="control-group">
                    &nbsp;<div class="controls">
                       
                    <label for="select01" class="control-label">
                        <span class="red">*</span>City:</label><asp:DropDownList ID="dropCity" BackColor="White" runat="server" AutoPostBack="True" CssClass="libox">
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="dropCity" ErrorMessage="RequiredFieldValidator" ValidationGroup="ValidRegDetail"></asp:RequiredFieldValidator>
                    </div>

Here is my selected index change event 

            lbl2.Text = "asd";
            dropCity.Items.Clear();
            cityService.GlobalWeather cityServ = new cityService.GlobalWeather();
            string result = cityServ.GetCitiesByCountry(dropCountry.SelectedItem.Text);
            XDocument xdoc = XDocument.Parse(result);
            var citys = xdoc.Descendants("Table");
            foreach (var tag in citys)
            {
                dropCity.Items.Add(tag.Element("City").Value);
            }
            Label1.Text = "asd";
            Response.Write("it is work ");

 This event only trigger when i use this button i think because it is postback page

   protected void Button1_Click1(object sender, EventArgs e)
        {
            lbl2.Text = "asd";

        }

I have to postback page without button when i selected country from dropdownlist page .
And I working on host (http://mstkacar.com/registerdetail.aspx) its my personal page.

Thanks..

Hi, You have a common validation group for both drop downs and that may be the problem. You need to post back on selecting coutnry, but you have same validation group mentioned for city drop down.

i deleted all validations still same :)

Not sure, try double click the DropDownList, type the code.
Set the action attribute in your form tag <form action="youraspname.aspx" >

<form action="youraspname.aspx" > i did  not worked thx for replies

Can you post your form tag declaration and the asp file name that you are working on?
<form id="form1" action="default.aspx" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            Current Time:
            <asp:Label ID="lblTime" runat="server" /><br />
            Session Value:
            <asp:Label ID="lblSessionValue" runat="server" /><br />
            <br />
            <asp:UpdatePanel ID="upSetSession" runat="server" EnableViewState="True">
                <ContentTemplate>
                    
                    <asp:DropDownList ID="ddlMyList" runat="server"
                        OnSelectedIndexChanged="ddlMyList_SelectedIndexChanged"
                        AutoPostBack="true">
                        <asp:ListItem>Select One</asp:ListItem>
                        <asp:ListItem>Maybe</asp:ListItem>
                        <asp:ListItem>Yes</asp:ListItem>
                    </asp:DropDownList>
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

                </ContentTemplate>
                 <Triggers> <asp:AsyncPostBackTrigger ControlID="ddlMyList" EventName="SelectedIndexChanged" /> </Triggers>
                
            </asp:UpdatePanel>

        </div>
        <div>
            <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
            <asp:Button ID="Button2" runat="server" Text="Button"   OnClick="Button2_Click"  OnClientClick="" />

        </div>
    </form>

also i can give u skype calling teamviewer sharing im spend so many hour for this…

http://brendan.enrick.com/post/dynamically-register-an-asynchronous-postback-control-with-a-scriptmanager.aspx

Hello oned_gk it  already worked when i clicked button.
Without using the button I wanna make it shown on the page with using SelectedindexChange Event.
I trace step by step SelectedindexChange Event worked.
The only problem is that I can’t make it seen on the page!

If your event is worked and you don’t see any changes on the screen then something is not working as expected in your selected index change event. Could you share your code?
protected void ddlMyList_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = "içteki oldu";
Label2.Text = "dıştaki oldu";
Response.Write("oldu abicim");
Session.Remove("MyValue");
Session.Add("MyValue", this.ddlMyList.SelectedValue);
//postbacktimer
//upSetSession.Update();
//PostBack
}

if u want i share my project too  
the codes working step by step but nothing displays on the  page

Just let you know that you can’t use Response.Write during an asynchronous postback (Update Panel). Remove Response.Write line in your selectedindex event.

its work when i delete it  hallelujah !

[RESOLVED]gridview unable to autorefresh

hi all … I’m having a gridview inside a update panel . I’m using timer control with triggers as well .

I want to make my grid autorefresh after a small interval . I tried everything , but unable to do so . 

I don’t have any code behind  for timer tick event . 

thanks and regards

Harshit Upreti

Astt Programmer , Indian Council Of Medical Research 
Bangalore 

 

Check this link

http://pankajlalwani.wordpress.com/2010/01/19/refresh-content-in-updatepanel-using-asp-net-ajax-timer-control/

http://www.devcurry.com/2009/03/how-to-refresh-aspnet-gridview.html

http://sanjevsharma.blogspot.com/2007/10/auto-refresh-update-panel-on-page-using.html

you can also use this code

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <Triggers>
        <asp:AsyncPostBackTrigger  ControlID="Timer1" EventName="Tick" />
    </Triggers>
    <ContentTemplate>
        <!-- your content here, no timer -->
    </ContentTemplate>
</asp:UpdatePanel>

<asp:Timer ID="Timer1" runat="server" Interval="5000" OnTick="Timer1_Tick">
</asp:Timer>

hi  sohail , thanks for the solution . The thing is I’, doing in the very similar manner . 

Here is my code snippet

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" Interval="10" OnTick="Timer1_Tick">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="tick" />
</Triggers>
<ContentTemplate>

…………………………………………………. </Content Template>

‘ve got nothing in code behind for Timer1_tick 

in your timer tick code behind. that’s where you should call the binding for the gridview. 

here’s what i use.

Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs)
        RefreshGrid()
    End Sub

hope this helps!

hello folks … Finally i figuered out the problem . As the goverment work is , so are their Pc’s . 

There was a problem in my web config file due to improper ajax installation in my pc . 

There’s no need to rebind grid in tick event though . Thanks for your solutions .

Jquery countdown timer

Hi,

I am using Jquery countdown timer from http://keith-wood.name/countdown.html. Its working fine at my local server. But on staging its not working. please check code below:

$(function () {
        try {
            var requestTimeStampDate = new Date($('.HelpDeskTicketTimeStamp').val());
            $('#divCountdown').countdown({ since: requestTimeStampDate, timezone: '' });
 
        } catch (e) {
 
        }
    });

If I wrap this code in Window.setinterval(function(), 2000) then its working fine on staging as well.
Can anyone help me to find out exact reason what is this doing in 2 sec interval.I want to work it properly without
any interval.

Thanks

There is a big chance, that your code is getting called before the DOM is ready, make use of jQuery.ready() to make sure that doesn’t happen:

$(document).ready(function() {
  try {
    var requestTimeStampDate = new Date($('.HelpDeskTicketTimeStamp').val());
    $('#divCountdown').countdown({ since: requestTimeStampDate, timezone: '' });
  } catch (e) {
  
  }
});

Also make sure that you are loading jQuery script file before above snippet.

Thanks for your feeback. I have tried this way but its not working. If its getting called before the DOM then why its working on my local machine.

Please check one more thing:

<div id="divCountdown" style="width130px;">
 <input type="hidden" class="HelpDeskTicketTimeStamp" value='@Model.RequestTimeStamp.ToString("dddd, dd MMMM yyyy HH:mm:ss")' />
</div>

this is div that contains countdown timer.

Thanks.

Is there any place online where I can test your code?

I can show you by team viewer. I can not share credential. Mail me on  if you are ready.

That will not be needed at this point. Please remove the try/catch and check wit IE (or better FireBug) if you are getting any JavaScript errors.

not working.

Yes, but those FireFox FireBug (or IE) console is yielding any js errors?

no error. below are some warnings yielded by fireforx….

Warning: Expected media feature name but found ‘-webkit-min-device-pixel-ratio’.
Source File: http://ibis2staging.o2mediainc.com/Content/themes/selective/css/style.css
Line: 412

Warning: Expected declaration but found ‘!’.  Skipped to next declaration.
Source File: http://ibis2staging.o2mediainc.com/Content/themes/selective/css/inner.css
Line: 29

Warning: Error in parsing value for ‘filter’.  Declaration dropped.
Source File: http://ibis2staging.o2mediainc.com/Scripts/fancybox/jquery.fancybox-1.3.4.css
Line: 327

Can you post the div once again, but from client-side (rendered by ASP.NET)?

<div style="width: 130px;" id="divCountdown" class="hasCountdown"><span class="countdown_row countdown_show3"><span class="countdown_section"><span class="countdown_amount">0</span><br>Hours</span><span class="countdown_section"><span class="countdown_amount">0</span><br>Minutes</span><span
class="countdown_section"><span class="countdown_amount">0</span><br>Seconds</span></span></div>

Ok, this is great. Can I ask for the same, but with countdown plugin code commented (generated by ASP.NET but not changed by countdown plugin).

Ok, this is great. Can I ask for the same, but with countdown plugin code commented (generated by ASP.NET but not changed by countdown plugin).

<div style="width: 130px;" id="divCountdown">
                    <input type="hidden" value="Tuesday, 13 March 2012 20:32:40" class="HelpDeskTicketTimeStamp">
                </div>

I have made a quick test and it seems that possible reason might be desynchronization between the server and the client. The date you are setting is actual "in the future" on the client side – that would cause countdown to not start counting. To verify that
please try with some earlier date, for example:

<div id="divCountdown" style="width: 130px;">
    <input type="hidden" class="HelpDeskTicketTimeStamp" value='@Model.RequestTimeStamp.AddMinutes(-5).ToString("dddd, dd MMMM yyyy HH:mm:ss")' />
</div>

its by default takes client machine time zone and start counting by 1 sec as we hit OK button because this time and client machine time is same.

As you hits OK button it looks 0 hour 0 mnt 0 sec. If you will refresh page on same moment it works and start counting with 3 sec or 4 sec, depend on how fast you refresh page.

I do understand what the idea behind your approach is, I’m just asking you to test because at this point this is only logical solution. The plugin is working (the element is converted into countdown) it just doesn’t start count (unless you use delay which
further proves this theory).

I have tried the same thing with .AddSeconds(-2) now its working but countdown starts from 20 seconds on stagin server and in case of .AddSeconds(-1) its not working.

[RESOLVED]Jquery Countup error

Hi,

I am using http://keith-wood.name/countdown.html. This is working fine on local server but on staging it is not working according to my expectation. On click of submit countup timer not starting and when I
refresh page then start working. Second behavior, if I used Window.SetInterval for 2 seconds then It works. Below is the code:

HTML Code:

<div id="divCountdown" style="width130px;"> <input type="hidden" 
class
="HelpDeskTicketTimeStamp" value='@Model.RequestTimeStamp.ToString("dddd, dd MMMM yyyy HH:mm:ss")' />
 </div>

 Jquery Code:

<script type="text/javascript">     $(function () {       
  try {          
  var requestTimeStampDate = new Date($('.HelpDeskTicketTimeStamp').val());           
 $('#divCountdown').countdown({ since: requestTimeStampDate, timezone: '' });      
  } catch (e) {         }     });
</
script>

If I write above code in 2 sec interval then it works. I want to know what is this doing in
2 sec interval or please help me to implement this to implement perfectly.

Thanks

Nothing looks wrong with the code.

Are you getting any exceptions in your try/catch?

Have you tried using the page onload instead of jquery’s to see if that makes a difference?

Do you have the countdown function include statement below your jquery include? If it’s above, this could happen but you are more likely to get an error.

Just a few simple ideas to try, hope 1 works for you.

[RESOLVED]Reloading only GridView on the page without postback

Split off from: http://forums.asp.net/t/1396102.aspx

i tried but even though its getting postback the complete page

Hi,

UpdatePanel is the right control you need to use. I think it is the best and easy way to implement what you want. For .aspx page I think they all use that one.

Using ICallBackEventHandler :

http://www.dotnetspider.com/resources/31322-Binding-GridView-using-CallBack.aspx

http://www.ajaxmatters.com/2006/05/creating-an-ajax-enabled-grid-using-icallbackeventhandler-part-1/

you can put a timer control and gridview inside update panel for auto refreshing

<asp:Timer ID="AutoRefreshTimer" runat="server" 
                 Interval="5000" 
                 ontick="AutoRefreshTimer_Tick"/>
 
refer Auto refresh gridview with timer for more info 
http://forums.asp.net/t/1702540.aspx/1

[RESOLVED]Ajax AdRotator and Page load behavior

Hello, When page refreshes due to time trigger, page focuses on that updated page portion, which is annoying. Please see this behavior here: (scroll page and you will be redirected to the same "Also Available On" section, I don’t want that): http://www.usmaniacomplex.com/Downloads/UCL_1_0.aspx and http://www.usmaniacomplex.com/Downloads/UKM_1_0.aspx . 

Code:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
   <ContentTemplate>

        // Comments panel

   </ContentTemplate>

</asp:UpdatePanel>

<asp:UpdatePanel ID="UpdatePanel2" runat="server">
   <ContentTemplate>
        <asp:AdRotator ID="AdRotator1" runat="server" Target="_self" DataSourceID="XmlDataSource1" />
        <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/some.xml"></asp:XmlDataSource>
        <asp:Timer ID="Timer1" runat="server" Interval="2000"></asp:Timer>
   </ContentTemplate>
</asp:UpdatePanel>

See if this helps you: http://forums.asp.net/t/1156877.aspx

http://forums.asp.net/t/1513472.aspx

Specifically the post with this snippet:

<script type="text/javascript"> var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(beginRequest);
function beginRequest() {     prm._scrollPosition = null; } < /script>

http://aspnet.4guysfromrolla.com/articles/111704-1.aspx

<pages smartNavigation="true"MaintainScrollPositionOnPostback="true"/>

http://basgun.wordpress.com/2008/06/09/maintain-scroll-position-updatepanel-postback/

[RESOLVED]How to call a javascript method from Sql Server 2008 Trigger

Hi guys,

Currently I am working on a task management system, and within that I have a requirement to implement a notification system which will display messages from sql server..Now I am not allowed to use javascript timer which will hit the database ina atimely
manner, so what I need is, to call the javascript function according the user assigned to that task from sql srver. Means when admin assigns a task to USER-A, that user should get a notification message from sql server automatically. Again I ama not allowed
to use any third party controls or library other than jquery. Please remember I am not allowed to use timer in this application.

Hope you people will come out with good solution very soon.

Awaiting for a fastest response from your side..

Thanks and regards,

Sriguru Pattanayak

HI,

As we know Web is stateless!
we can invoke servercode when browser requests/connects.(vice versa may not possible).
If u r refering email notification, then sqlserver can do that!
if its webpage notification:
then its possible if user checks his home page later,
if thats not the case, i think thats not possible if user is online(without timer/ajax)!

alternatively try checking this:
http://www.hanselman.com/blog/AsynchronousScalableWebApplicationsWithRealtimePersistentLongrunningConnectionsWithSignalR.aspx