Showing posts with label fire. Show all posts
Showing posts with label fire. Show all posts

Wednesday, March 28, 2012

change scroll position on partial-page update?

I'm wanting to be able to change the scroll position to the bottom (or to an anchor) on an AJAX partial-page update. Any ideas? Can I fire a client-side javascript function after the update? Do I have to turn off MaintainScrollPositionOnPostback for the page?

Seehttp://forums.asp.net/t/1157991.aspx

Also, if you have specific scrolling logic when the UpdatePanel comes back, you can add it to EndRequest method in the following code (e.g. scrollTo)...

<script language="javascript" type="text/javascript"> var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_initializeRequest(InitializeRequest); prm.add_endRequest(EndRequest); function InitializeRequest(sender, args) { ... } function EndRequest(sender, args) { ... } </script>

-Damien


Thanks... that's what I needed!

Brad


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

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

Try this also

<script type="text/javascript"
var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_beginRequest(beginRequest);

function beginRequest()
{
prm._scrollPosition = null;
}

</script>

Lety me know if this helpful to you

Monday, March 26, 2012

Cause a JavaScript Function to run after update (update panel postback)

Hello,

I ran into a problem that im not sure if the Atlas framework addresses.

I need to fire off a javascript function (which is decided server side)on a postback. To do this I am going to be using a hidden input field.(since I already have one on the form I use to send information forserver use.) From the server side, I can place the function names intothe hidden input field. But I can't cause them to run, on each postback.

I suppose that is confusing, let me try something simpler.

1. I fire off a postback in javascript - This is done using the__dopostback() and the server side fires off its if statements and doesits functions based on what has been placed into my hidden input field.(this is all good so far) (if I had to I could use the body's on formload ability to fire off the javascript functions I desire, but thatwont work for the next step, and is really ugly)

2. I include Atlas to make my postback not refresh the whole page. This is done by using UpdatePanels.

3. On the server side I need to somehow tell it to run certainjavascript functions when that postback finishes loading. (so like onpartial page load)

How do I do step 3?<script type="text/javascript">
function AfterPostback()
{
alert("This is where we check the hidden input and run the functions.");
}

function PageRequestManagerPropertyChanged(sender, args)
{
if (args.get_propertyName() == "inPostBack")
{
if (!$object("_PageRequestManager").get_inPostBack())
AfterPostback();
}
}

function pageLoad()
{
$object("_PageRequestManager").propertyChanged.add(PageRequestManagerPropertyChanged);
}
</script
<div>
<atlas:ScriptManagerEnablePartialRendering="true" ID="ScriptManager1" runat="server">
</atlas:ScriptManager>
<atlas:UpdatePanel runat="server" Mode="Conditional" ID="UpdatePanel1">
<ContentTemplate>
<%= DateTime.Now.ToLongTimeString() %>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="UpdateTime" EventName="Click"/>
</Triggers>
</atlas:UpdatePanel>
<asp:Button ID="UpdateTime" runat="server" Text="Update Time" />
</div
Thats the solution I rigged up.
Hi,

Thanks for posting your solution. It works very well and solves a whole bunch of missing stuff with AtlasPanels. One problem dough. I had to move the call to JS function pageLoad() to the end of the html file part instead of putting it to body onload event.
Another option for doing this is theUpdateProgressSignup extension.

CascadingDropDowns cant fire OnSelectedIndexChanged client events?

Greetings, all...

I've got a page with a CascadingDropDown setup. On the third dropdown, I want to fire an update panel event to fetch data.

For whatever reason, it does not appear that I can get any of the three dropdowns in the cascade to recognize a client-side OnSelectedIndexChanged event - even when added programmatically in the code file.

The event/action are emitted correctly to the control, but it doesn't seem to fire the event.

I've been trying to find the answer in previous posts and Google, but I don't seem to be finding the answers anywhere. I'm hoping there's someone out in forumland that has seen this before and knows how to resolve the issue.

Thanks in advance for the help,

Ric Castagna

Unless I'm mistaken, OnSelectedIndexChanged is a server-side event, not a client-side one.

Saturday, March 24, 2012

CascadingDropDown: Fire an Event

I have created a custom control that contains 3 CascadingDropDown boxes.

I would like to have the control fire a custom event when each of the "TextChanged" or "SelectedIndexChanged" events from the Drop Down items change.

I have added the appropriate "events" into my code behind, but they do not seem to fire. Does the JavaScript intercept them?

Any help would be greatly appreciated.

Thanks,
Bryan

The Changed events you rever to are server-side events that only fire when there's a postback. By design, CascadingDropDown doesn't do postbacks. So you don't get those events when using it. You could force a postback, but doing so would seem to negate many of the benefits of the CDD.

Mr. Anson,

Perhaps you could point me in a better direction for my needs.

The Custom Control that I have created consists of 3 CascadingDropDowns that allow the user to select a Location, Skill, and Supervisor (basically this is like the Make/Model/Color sample for the car.).

My control works fine when I incorporate a button to run a report on a different page. My Button_OnClick event can see what values are in my control, and it will send them to the new page.

I would like to incorporate my current control on a page to help narrow down yet another Drop Down List.

In the CDD example, after the user selects the Make/Model/Color, I would like to pull a list of Vehicles by Year to select.

How would I go about hooking up a new CDD that requires the control to have filled in the Make/Model/Color before it can go out and find it's data?

I thought that I could do something like placing the control and drop down list inside an update panel, but I am a little fuzzy on how to continue from there.

Would I need to set up an Atlas Trigger?

Any help that you can provide would be greatly appreciated. It would even help if you could point me in a better direction.

Thanks, Bryan


Could you add a ByYear CDD that has the Color CDD as its parent? That way it automatically populates when the Make/Model/Color are filled in. And it's welcome to call a completely different web service, so it can get whatever data it wants.

If my Make/Model/Color are in a seperate control, how will I be able to give my Year CDD the parent that is inside the control? Can I just expose the CDD as a public member?

I don't want to add the Year CDD into my control. A different page may want to populate a different CDD from the data that the control provides.


You could manually hook some script up to the "onchanged" event on the client-side select element, but it's probably ultimately the same problem as above with respect to how the Year can see into the control to get the right elements.

Wednesday, March 21, 2012

CascadingDropDown needs to fire "SelectedIndexChanged" from client-side

It seems I always end up with more questions than answers...

So...here's the scenario this time.

I've got two dropdownlists, Make (ddlMake) and Model (ddlModel) with a CascadingDropDownExtender attached to ddlModel. Obviously, when the user changes the Make, I need to retrieve the appropriate Models based on the selection. No problem, that part works just fine.

The twist is this: When I load this up into a ModalPopup, a record is going to (pardon the pun) drive what's being populated into ddlMake. I'm using Javascript to .show() my ModalPopup after I've looked up the record, so the code goes a little like this:

function showModal(object)
{
var _ddlMake = document.getElementById("<%= ddlMake.ClientID %>");
var _ddlModel = document.getElementById("<%= ddlModel.ClientID %>");

// Dummy for now, will be pulled from the loaded record
_ddlMake.options[4].selected = true;
_ddlMake._onParentChange(null,null);

var _popup = $find(object);
_popup.show();
}


Some of the posts I've seen suggested the _onParentChange(null,null), but Firebug is barking saying "_ddlMake._onParentChange is not a function". Granted, it's one of the internals of the CascadingDropDown, but others have stated that this is the way to do it.

What I'm wondering is how to do this. I can't believe that I'm the only person to have ever thought of needing to set/fire these events from the client-side. I'd love some help on this one, that's for sure!

Thanks in advance,

Ric

Bump...still needing some help...