I am using the plugin Chosen of jQuery in asp:DropDownList. When selecting the data, the selected field activates the AutoPostBack and the Chosen property is lost. The asp:DropDownList returns to be the same. Does anyone have a possible solution? I can't place the false autopostback.
Thank you
Chosen : jQuery plugin...does not work after postback in asp.net I have used this link but it is confusing for me how to apply it in my case.
Related
I know this is a problem that's been asked a few times before, but having had a look around I can't seem to find an answer that works for me.
I have a VB.NET page with 2 textboxes (set to show dates using JQuery), a dropdownlist and a datagrid.
Both textboxes and the dropdownlist are set to fire events, if they're changed, to update the datagrid.
Generally this works fine with one exception; when I change the value of either the textboxes or the dropdownlist after the initial page loading it often doesn't fire the event, the postback is set to false and the dropdownlist value is cleared; this doesn't happen in Chrome and is less frequent in Firefox than in IE.
I've tried the following:
I've set autopostback=true on all items
Tried adding an extra item, which isn't enabled, to the dropdownlist
Moved the boxes/List outside the update panel
Set ViewStateMode=Enabled
Tried adding a hidden field which is set to Request.Form(ddlDropdownList.UniqueNumber) and comparing it to Request.Form(ddlDropdownList.UniqueNumber) in the page load as a way to fire the event (the suggestion says to use Request.Forms, but this isn't coming up as an option on intellisense?)
All of these solutions either don't work, cause other issues, or I'm not doing them right (Which could certainly be the case)
Thanks in advance for any help you can give.
I don't know if this will help, it's been a while since I've done web forms, but I do recall there being a problem with listboxes where I had to check if the page was not on a postback when populating it.
So basically in your page loading method, check to see if the page is not a postback before initalising it. I found that even though I selected a new item, it was resetting the list back to it's default state.
This may or may not help you, but I thought it was worth at least mentioning it.
I am having a couple of issues with the MovePrevious Button in the ASP.Net Wizard Control. I am trying to prevent it from firing the validation on the controls in each step. The attempts I have tried are:
1) Setting the CauseValidation on the button to false
2) By finding the control id for the button and coding it not to fire in the MovePrevious Event in the code behind.
Neither of theses are working, and I am clean out of ideas, and would like to know if anyone has a solution to this issue.
Lastly, and this is final question, as the wizard control keeps the history, if the user returns to the first step, is there away to clean down the history in order that the wizard starts a fresh? I used the GetHistory Method, but this seems to screw up the binding of drop down lists.
You can use ValidationGroup property
For your validators controls you set one ValidationGroup1
And for your button you set another ValidationGroup2
Link : http://msdn.microsoft.com/fr-fr/library/system.web.ui.webcontrols.basevalidator.validationgroup%28v=vs.80%29.aspx
I have one dropdownlist (with static listitems). On SelectedIndexChanged event of this dropdownlist, I have three cases to check:
1) If the value is 'A', I need to bind another dropdownlist.
2) If value is 'B', I need to hide above another dropdownlist and instead show nothing in place of that i.e. ulitmately hide that particular div.
3) If values is 'C', I need to hide above div and in place of that, show a textbox.
Now, to prevent Page postback each time a value in dropdownlist is changed, I am using UpdatePanel control here.
I have tried using single updatepanel for both these dropdownlists, two separate udpatePanels for each of them.
With two separate updatePanels, I could succeed in calling the "SelectedIndexChanged" event of that dropdownlist, but once the event is called, the changes done in that code are not reflecting on the page.
i.e. if I hide a div when selected value is 'B', it still shows me, or in either case if it is 'A' and I bind another dropdown, it does not even render.
And, if I reload that page, the pervious changes get reflected. Can anybody please tell me what could be wrong here?
Also, please note that I want be able to postback the page programmatically, because that is the I am trying to prevent.
Also, I would like to notify here that I am using all these things in a WizrdStep of an asp.net wizard control.
Would be greatful for any help.
Thank you in advance.
The issue was not because of update panel or dropdownlist.
The problem was with the way my page was being rendered.
I have used url rewriting for my application and I was trying render this page using my customized form tag instead of built-in Html form tag.
That is why updatepanel was not working normally.
I have got it working now using normal Html Form tag and meanwhile I am trying to workout to handle this updatepanel tag as well with my customized form tag.
If I get it solved, I will submit the solution.
Thanks.
I seem to have a bit of a bug, I have a ASP.NET repeater control with a link buttons in it and the link button has the have the causes validation property set to false.
However; when clicking it which makes a panel visible on the web page, the asp.net required field validator controls trigger and shows their error messages. On those controls that I have the validator controls on.
Any ideas as to what might cause it to be ignoring the causes validation property set to false?
On my opinion, you should set different ValidationGroup properties values for repeater control and for control that is the source for required field validator. It is possible that container for repeat control has raised event that can be heared by required field validator.
If mentioned above cannot help then try to disable client validation for RequiredFieldValidator using EnableClientScript="False" for it. And activate RequiredFieldValidator when it really usefull. For example in the some button event handler you can apply such code:
MyButton.Validate();
if (MyButton.IsValid)
{
Do what you want...
}
For anybody that has this problem and stumbles across this post, here's what I found.
Turns out the problem was happening because I had EnableViewState="false" set on the Repeater. This was breaking the event postback somehow, and making every validator on the page fire. All I had to do was manually call DataBind() on the Repeater from within Page_Load(), and it cleared right up.
try to set the visablity of the panel true all the time in design view,, and check the validation again.
Problem: Content Page with Wizard Control with UpdatePanel and Placeholder. Above the UpdatePanel is a DropDownList. I need to display different input controls below the drop-down list when the user changes the selection in the drop-down list. When the user clicks 'Next' on the wizard control, I need to be able to get the data out of those dynamic controls as well.
I know all the dynamic controls have to be created in the OnInit method in order to get the data back from those controls during the postback. However, when the drop-down list's SelectedIndexChanged event is fired, the OnInit method is called... then the PageLoad... and finally the handler for the SelectedIndexChanged event is called. ViewState hasn't been restored until well after the OnInit & PageLoad methods have been called, so there is no way to know what the user chose in the list box at the time OnInit is called... which exactly when I'm required to create the dynamic controls.
So... how do you solve this problem? Do you just have to write the entire page, or most of it, using JavaScript?
Thanks in advance.
I tend to use an old school method for this type of requirement. I would write all of the controls that are needed in the update panel, with their Visible property set to false. Then, on post back read the drop down's state and set the approperate controls Visible property to true. This way there is no "dynamic" controls, and due to the fact that controls whose Visible property is false are not rendered, they are not downloaded until the user should see them.
you can also use an asp:hiddenfield and set the value to a case var you mentally create. then run a small jQuery script on top to look at
$(document).on("change", "#ddlSelector", setControls);
then just make a function, for instance:
function setControls(event) {
event.preventDefault();
var selector = hiddenfield.val();
}
then any item to show/hide can be done with getting the tag:
$("#elementName").css("display", "inline");
or display, none to hide.
I used this at work because at times you need to change without firing the postback, but still collect data when they engage the form.
I typically avoid jQuery for many events for strength of code and security, but DOM element manipulation can be much easier at times with jQuery.