RadioButtonList SelectedIndexChange Even on pop form - javascript

Hi all I have a problem with my pop up form in javascript. I using even of RadioButtonList my pop up close. So my question is how should I use RadioButtonList Even on pop up form without closing?

This is most likely because you are posting back the form and the changes made with javascript haven't been stored in the view state.
One option would be to use an UpdatePanel (assuming you mean ASP.NET and not ASP?) around the RadioButtonList to prevent a full post back.
http://msdn.microsoft.com/en-us/library/bb399001.aspx

Related

Dropdownlist Postback interferes with Javascript

My ASP page has a DropDownList (DDL) and a bunch of checkboxes. When my user selects a DDL item, I have some JS/jQuery code to make several checkboxes invisible according to some logic. However, the postback of the DDL, needed to run the C# code-behind event handler, causes a redraw of the entire page and makes all checkboxes visible.
How can I prevent the postback from wiping out the actions of the JS? Should I store visibility bits in something like ViewState?
Is it possible to have the JS code run AFTER the postback, instead of before?
Is it possible/easy to use CallBack instead of PostBack for the ASP DropDownList? I was thinking that the fun of Ajax was avoiding postbacks and only updating the control instead of the entire page.
Well if the dropdown posts back in the same action that you flip the switch for the checkboxes, why not then put the logic to show/hide checkboxes on the server instead of the client? You can use the hidden field approach, and that would work fine.
The callback means the UI needs updated by JavaScript. I don't know what all the postback updates, but you would have to send everything up via JSON, and refresh the UI via JavaScript. So only you can make that call.

Javascript reload, but keep post variables

I'm working on a script, and if a button is pressed, I want the page to reload. However, I want to keep the current values of my POST-variables.
I'm using JavaScript, and I've tried location.reload(), but I lose the variable values. However, if I press Ctrl+R (refresh), I get the alert box which asks if I want to keep the POST-variables.
Does anyone know how to keep POST-variables when you reload a page using JavaScript?
In the onclick handler for the button you could create a form programmatically, fill it with hidden inputs that reflect the names and values of your variables and finally submit that form.
You will have 2 opportunities:
Store the post variables in a hidden form an submit this via javascript
Use session handling
http://www.php.net/manual/en/function.session-start.php

ASP.Net suppress postback for combobox only for OnSelectedIndexChanged

I am using an AJAX ComboBox in my ASP.Net web application and I have an OnItemInserted event that requires a postback to hit the server side logic however this requires that I have AutoPostBack = True. This causes an unwanted effect of OnSelectedIndexChanged event triggering a Postback causing the control to lose focus.
More background: This combobox resides inside of a fairly complex gridview which contains other comboboxes, dropdownlists, and textboxes. My objective is to allow the user to smoothly tab through the row while entering data without having to use the mouse to promote rapid data entry.
I believe that I need to utilize javascript to suppress this postback but I am open to suggestions.
You can suppress the postback by simply returning false on the relevant client event:
http://edgewaters.blogspot.com/2008/01/button-that-doesnt-post-back.html
OnSelectedIndexChanged="return false"

Restore dynamic Telerik RadWindows on next postback

I'm doing some ASP using Telerik.
On my page there are 2 buttons called Create Window and Postback. The Create Window button created a new RadWindow dynamically on it's click event (client-side) by using window.radopen(). The Postback button simply does a postback. My problem is that, the windows get lost after every postback. What can I do to make my RadWindows to remain opened after a postback, including its content and position.
If there is no built-in function to restore my dynamic RadWindows, please tell me how to save current windows content to manually load it on the next postback. I thought of using a Hidden control to save my RadWindow position and content, but how can I do that (it's content is a user control with plentiful textboxes, and i don't want my customer to re-type all the textboxes).
The RadWindows are generated via JavaScript when they are first shown. You can easily check this via your developer plugin of choice. Once you show them they create their wrapper div as a direct child of the form element. This means that they have no server-side rendering and thus cannot be persisted on the server across postbacks.
What you can do is use AJAX - have the button perform an AJAX request that will update the needed content of the page, but will leave the RadWindows out of the update. Check out this help article where they explain how to use AJAX with a RadWindow: http://www.telerik.com/help/aspnet-ajax/radwindow-ajaxifying.html.

ASP.NET MVC Dropdown list on change to cause postback without Javascript

Is it possible to cause a postback to an action from changing your selection in a dropdown list without using JavaScript?
I remember when using the ASP.NET Forms dropdown list control, there was a property that when set would cause a postback on change, did this work without JS? - If so, how?
Many thanks,
Kohan.
You can achieve the postback effect using jQuery. JavaScript in some form or another is required for automatic postbacks. Even ASP.NET uses JavaScript in the background to implement the AutoPostBack property.
<script type='text/javascript'\>
$('#dropDown').change(function () {
$(this).parents('form').submit();
});
</script>
You need JavaScript to automatically post back data. You don't have to write it, but you still need it. You can post without JavaScript (someone pressing a submit button), but not automatically.
I believe what you are thinking of is the AutoPostBack property.
Do this:
More here:
How do you submit a dropdownlist in asp.net mvc
Complete script which worked for me
#Html.DropDownList("Projects", Model.Projects, new {
style = "Height: 25px; width: 225px;",
onchange = "$(this).parents('form').submit();" })

Categories