Showing posts with label button. Show all posts
Showing posts with label button. Show all posts

Wednesday, March 28, 2012

AJAX UpdatePanel Refresh != Browser Refresh

Hey everyone. I've got a problem, I have a page that I want the data and buttons to refresh every 30 seconds. When I click the button, the data is recorded into a database and the button(s) are disabled until the next interval comes up. An interval is 5 mins even though the data will refresh every 30 seconds. That means that when the button is pushed, it should be disabled until the 5 min interval is up.

The problem I'm having is that even though my whole page is in the Update Panel, my buttons DO NOT re-enable after that 5 min interval, but my data labels DO. I have an indicator that changes at each 5 min interval and it is working, but my buttons are still disabled. I can refresh the page and the buttons are enabled...another thing is that after I press the button and it's disabled, I can refresh the page and the buttons still stay disabled as thy should until the next 5 min interval.

Is the entire Page_Load called on the AJAX Update Panel refresh? It doesn't seem like it since my code that enables/disables my buttons is not being called. Any ideas?

What is the full page refresh doing that the AJAX Update panel is not? I would just do a normal page refresh, but that looks bad and I'm also using the collapsable panels and the normal page refresh call would collapse all the panels. That would make the use of them, well, useless.

try call the update function of the updatepanel

<asp:UpdatePanel ID="Test" ...

code behind ... Test.Update()

if not then use javascript to set the buttons back to disabled = false;


The data refreshes fine still, but the buttons don't "reset."

Baseically, I have a function that is called for each button that looks in the database to see if a log has been made for this record. If there is not a log, the button is enabled, if there is a log, the button is disabled until the next interval. For some reason, my functions that check my buttons are not being called when the update panel is updated each 30 seconds. The functionality when the button is clicked works fine, but the buttons never enable again unless I hit the refresh in the browser to refresh the entire page.

I hope someone else has some suggestions as to what might be going on. Thanks!


Ok, here's the answer of why my "AJAX UpdatePanel Refresh != Browser Refresh"...

In my old version of the page, I have the default value of my buttons set to enabled. Each time the page refreshes, the default value is seen. In the AJAX update panel, the default value is not seen and therefore my buttons were not resetting to the default. My functions were assuming these would be enabled unless the log was found.

I hope this helps someone that might have the same problems in the future.

Ajax Update panel button disable/enable

I am trying to disable a button after the request begins and then enable when the request ends. I've gotten the disable part to work but it does not enable it. What am i doing wrong? Here is my code.

Thanks.

<formid="form1"runat="server">

<ajaxToolkit:ToolkitScriptManagerrunat="server"ID="ToolkitScriptManager1"EnableScriptGlobalization="true"EnableScriptLocalization="true"></ajaxToolkit:ToolkitScriptManager>

<scripttype="text/javascript">

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(HideButton);

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(ShowButton);

function ShowButton()

{

$get("Button1").disabled ="false";

}

function HideButton()

{

$get("Button1").disabled ="true";

}

</script>

<div>

<ajax:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<asp:ButtonID="Button1"runat="server"Text="Button"OnClick="Button1_Click"/>

<asp:LabelID="lblTest"runat="server"></asp:Label>

</ContentTemplate>

</ajax:UpdatePanel>

<ajax:UpdateProgressID="UpdateProgress1"runat="server"AssociatedUpdatePanelID="UpdatePanel1">

<ProgressTemplate>

processing.....

</ProgressTemplate>

</ajax:UpdateProgress>

</div>

</form>

Hi Azminer,

My understanding of your issue is that the button you disabled when beginRequest event is fired cannot be enabled when the partial-update finished. If I ahve misunderstood you , please feel free to let me know.

I think your problem is caused by this sentence ($get("Button1").disabled ="false") that you have assigned a string value to a bool variable. Here is my sample:

<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(HideButton);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(ShowButton);
function ShowButton(){
$get("<%=Button1.ClientID %>").disabled = false;
}
function HideButton(){
$get("<%=Button1.ClientID %>").disabled = true;
}
</script>

By the way, in your situation, you can get the same result without doing anything in endRequest event since the elements inside the UpdatePanel has been refreshed.

Best Regards,

Jonathan


Thanks Jonathan!

AJAX Update Panel and DataGrid

I write code to populate a datagrid with a Datatable stores in a session variable, I put some data in text boxes and click ADD button it stores that data in table and assign that table to a session variable. FINE.

When I click a datagrid item to Edit. Occasionally it says "Index is out of bound...". It is not always and not always with every row of datagrid. I click on another row to edit it works fine.

I do not know what is actually going inside AJAX. because of using AJAX my ADD and EDIT functionality do not refreshes the page but update the content as required.

Any body know that what should I do?

Regards,

Ather Ali Shaikh

I had a similar problem. I found that on every command I had to recreate the dataview (what I was using) where I used the info from the dataview then things were fine but if I didn't I would get out of bound errors as well as other weird messages. I wasn't trying to use the edit feature of the GridView but just displaying info when a link in a the GridView was clicked so you may also run into things I've not yet found. Anyway, hope this helps some.

Hi,

I do not use the Edit template of the datagrid, what I am doing is using template columns contains Edit link button and on capture is command click event on datagrid on Command event handler.

ajax update panel

hi, I have a problem with ajax.net controls. I have a form with some field. When I click a button I validete client-side the fields and then, only if the validation is ok, the page post his data to the same page. It works fine. Now I need to add the updatecontrol (ajax.net) with the script manager. If i do this the page make the validation control and even if it is not ok the page post his data. Why?

thanks

This my be what you need.

http://weblogs.asp.net/lkempe/archive/2007/03/26/asp-net-ajax-and-asp-net-validators.aspx

Ajax Update Panel

Hi guys,

I am using a login page with ValidatorCalloutExtender controls to validate username and password textboxes. On the submit button, I am using UpdateProgress to display an animation while the request is being entertained. Now, when the button's pressed, the animation comes up properly and everything is ok. However, I want the button to be disabled while the "progress" animation is being played and as soon as the results come back (like account not found), I want the button to be enabled again for the user.

How can I switch between the 2 states of the button as above? I would appreciate all help.

Thanks!

Found the solution :)

<scriptlanguage=javascript>

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

function BeginRequestHandler(sender, args)

{

var btn = document.getElementById("<%= BtnSubmit.ClientID %>");btn.disabled =true;

}

function EndRequestHandler(sender, args)

{

var btn = document.getElementById("<%= BtnSubmit.ClientID %>");btn.disabled =false;

}

</script>

AJAX UI and the old BACK BUTTON problem

Hi,

I googled "disable back button" and all solutions are fine for a standard ASP page but not for an AJAX UI. I can and do want to redirect my user to his last action inside my javascript code. But this of course only works if I can catch and reassign a new function to history.back(). Assigning a new function works (alert history.back gives me my code) but obviously the browser does not use it.

With AJAX this is a SERIOUS issue. Of course I can open the page in a new control less window, but even that at least the old IE with a tab add on screws up by opening the window in a tab.

So is there any solution for this ?

Thanks

Joe Robe

Hi,

While mainly focused on security, in one of the two (in the series of five), vids that are available on-demand already, Joe Stagner mentioned that they would be looking at this issue in an upcoming webcast. This is, after all security related, in that you need to know what is going to be executed - if and when. Beyond that, he mentioned that he is revising (again), the tutorial AJAX vids available in the Learn section of asp.net. Take a look at his site http://joeon.net for links for the on-demand webcast, or to sign up for the live Meeting editions still available (one a week, I think). As these have Q&A sessions, you'd have a shot at posting your question directly. Hope it helps. BTW, if you get a good answer - remember to pass it along. BRN..


In every page or in mater page add a script that will execute on page load. This script should imitate FORWARD button on the web browser. Note that it will do nothing if there is nothing in web-browser forward history. Since every page of your app tries to skip forward one page then one-by-one your browser will advance to the very last page in web-browser history.

history.go();


Take a look at Nikhils solution to this problem:

http://www.nikhilk.net/BackButtonSupport.aspx

Saturday, March 24, 2012

AJAX Tabs button click event is not working

Hi there,

I am use AJAX Tabs control and placed a quite few buttons in each tab panel.

But when I run the from its change the tabs but when I am trying click the buttons inside the tab panels it is not woring. just stand still. no event being save,reset, redirecting.

I have even tried to put whole tab container into updatepanel and write is postback triger to that buttons but that also it not worked.

Is any one have some suggestion post it...

can u post your code..


Hi Geek,

Kindly find the code below in which when I am try to click the button which is placed inside the tab panel it is not working.

<cc1:TabContainerID="TabContainer2"runat="server">

<cc1:TabPanelID="TabPanel4"runat="server">

<HeaderTemplate>Home

</HeaderTemplate>

<ContentTemplate>

<asp:TextBoxID="date1"runat="server"></asp:TextBox><cc1:CalendarExtenderID="CalendarExtender5"

runat="server"TargetControlID="date1">

</cc1:CalendarExtender>

<asp:ButtonID="Button1"runat="server"Text="Button"/>

</ContentTemplate>

</cc1:TabPanel>

</cc1:TabContainer>

what I was trying is when he select that date & click on the date selected I have the data in database which I have to show in grid...

Just have a hands on it if you find any thing.

just post it...


You are not written the Click event of button, so it was not working..

if i select the date and press on the button , it will give me the selected date, now then you can do any operations that you want..

Wednesday, March 21, 2012

AJAX TabContiner control

I am using the tabcontiner control, upon which I have placed 4 tabpanels. Based on the user clicking a button on one tab, I need to be able to disable all other tabs to prevent the user moving away unless they complete the operation, or cancel. I have tried to use the following

TabPanel1.Enabled =True

and

Me.TabContainer1.Tabs(0).Enabled =False

Unfortunately I have had no luck, any suggestions?

Michael.

When you set the TabPanel.Enabled = false it will disappear as I have just tested. I don't know if this is the desired effect that you are looking for or not.

You may want to set the AutoPostBack to true and then hook up an event to OnClientActiveTabChanged so that you can disable the other tabs. Of course you will want to wrap an update panel around the tabcontainer for a better client experience.

I hope this helps.


Hi Jim

Making the tabs disappear would be an acceptable solution, however, the above command will not even do this for me. I will give a look at your solution.

Michael.

Ajax Tab Container selected tab

I have a vb.net/asp.net 2005 app using an ajax tab container with tabs inside it.

I want the user to be able to click on a button as one way to get to the next tab. How do i display the next tab when the user clicks on a button.

Also, can I disable tabs where the user has not filled in information yet for the tab? IE: the user needs to fill in details on each tab page and the details are needed in sequence.

thanks.

Hi!

On the first one, you could put your TabContainer inside an UpdatePanel, set your button as a trigger and on the ButtonClick event set the TabContainer.ActiveTabIndex.

On the second one, you could use the same approach, using some kind of validation, catching the OnTextChangedEvent, so when you find that the user had filled up all the necessary information, you could enable a new TabPanel.
There are a couple of catchs here: Clicking on a TabPanel doesn't fire a post back to the server and I think that disabling a TabPanel won't just make it inactive, it will make it invisible. I'm not sure on the later, just give it a try.

Cherrs,