I am trying to get the value of the label to change each time a new date is selected. What is the best way to do this?
I have tried using page load and page init function to set it after each action as I thought the page would refresh automatically but having no luck. I am probably going down wrong path with that approach.
Any suggestions much appreciated.
If you want the page to refresh which will make it call the page load function again then you will need to set the AutoPostBack attribute of the calendar picker to True.
Or on the SelectionChanged event in the code behind of the calendar you can say
lblA.Text = calendar.SelectedDate
Related
My site uses a Calendar control to determine what date to get data for.
Because this calendar should be visible on every page, I've placed it on my MasterPage.
If the date on the calendar is changed, it should cause the data shown in the Content page to be updated with data specific for the new date. Essentially, it should cause the page to be reloaded.
Because the calendar is on the MasterPage, that's where I'm putting the SelectionChanged event handler, but I'm not sure how to "reload" the content page from here. All I can think of is a Response.Redirect, and I'm not sure if that's the best option.
Can anyone give me any suggestions?
Decided I'd simplify this and make the master page element a hyperlink that redirected to a page that had the calender on it and "Save" button on it.
I found this much easier to manage...
The calendar loads with today's date, allows the user to select another date and the save button writes the new selected date into a session variable read for the data that is to appear on all the content pages.
It means the user has to specially go away from what he/she is currently doing in order to set the date, but I actually prefer it this way.
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 have an aspx page. This page is used for both create and edit.
While editing, I set a session variable and load the same page.
While creating , user has to click on menu option and it get redirected to "CreatePage.aspx".
While editing, it will be redirected on click of a column in a grid . this time the response.redirect happens to the same page with Session["Id"] set to some value. Now my question is how and when do I set the session to null?
This should work for Create and Edit using the same page. Any help will be greatly appreciated.
The how is easy:
Session["Id"] = null.
About the when: Can the user cancel a edit/creation? If so, what happens then?
The change of the session variable should be done when the user clicks on either the menu option or the grid column AND when the operation has finished (by either an OK or a Cancel).
Anyways, Changing data in a grid can easily be done with the GridView control. You can see an example here. So you might be trying to "reinvent the wheel" here...
I would like to like to trigger a postback after user selects a date. Am using the AjaxControlToolkit's CalendarExtender control. The date textbox which is associated to the extender is editable too which enables the user to manually enter the date in a particular format. Values of quite a few controls which reside on that page are to be updated depending on the newly selected date and hence going to the server is a must.
I did try using the OnClientDateSelectionChanged property of the extender which lets me hook in my custom javascript, using which i was planning to trigger a postback but for some odd reason the function gets called only if the date is selected using an extender and not when manually edited (Hoping that it doesn't catch the click event over textbox's change).
Am sure many have tackled this issue before. Please do share. Thanks.
Here it is, Keep It Simple as they say. Set AutoPostBack of the text box to true and capture the OnTextChanged event on the server side.
I have a DropDownList on an ASP.NET master page and I want to change some values and refresh the page when I select a different item from the list. I enabled the post back property in the DropDownList but it still gets back always to the first value whenever I select. Any advice?
Please post some more code to show where you are setting the value of the dropdown (both on load and anywhere else).
Usually, this is just a case of not understanding the event model. Try setting breakpoints on all of those points where you set the value and step through the code.
The most obvious case would be if you're setting the value in the page_load event handler and not wrapping it in a check for !Page.IsPostback