I have used GM's datepicker control inside update panel.Inside update panel one more control(dropdownlist) is there.Onpageload everything is working properly.After Onselectedindexchange of dropdownlist,user can select datepicker's value.It is not working.How to handle this?
// update panel
// datepicker
// dropdownlist
// close updatepanel
You have to unbind/bind your datepicker to your TextBox every time the page (re-)loads. I don't know how your timepicker works, but with jQueryUI's you can use something like that (js):
function pageLoad() {
$("#myTextBox").unbind();
$("#myTextBox").datepicker();
}
Your textbox should use ClientIDMode="Static" for that.
Related
I have a GridView with a Textbox and when the user changes the text within that box, I want them to be able to hit the enter button and postback and update the changes they made within that textbox on the row in the GridView.
I can't figure out how to do this?
Thanks,
Mark
You need to use some JavaScript code to do that - its on the page part. Here is one that I use (jQuery)
$(document).ready(function(){
// capture the editors
var AllEditors = jQuery('#<%= gvGridViewID.ClientID %> :input[type=text]');
AllEditors.keydown(function (e) {
if (e.keyCode == 13)
{
e.preventDefault();
// the [value=Update] is the default value to Update control of GridView
jQuery(this).parents("tr").find("input[value=Update]").click();
}
});
});
If you have it inside UpdatePanel, you need to initialize it each time the UpatePanel fires. If you have it inside a custom control, you need to add extra variables on the function names to avoid conflicts.
I have web forms page that has 2 controls. A gridview and an associated listview.
When i select the record in gridview the page posts back and i see the details of the gridline in listview which is located below the grid.
Now i want to transfer the listview to a jquery dialog control.
I have tried to find a solid way to do it but i am confused. the moment the dialog appears its closed , apparently because the postbaxk occurs in order for the detailsview to load..
Any suggestions?
Should i have to drop listview in a separate page and then call the page from the grid inside a jquery dialog? (how?)
Is there a way to call the listview and show it in a dialog box instead of showing it below the gris?
Thanks
Update1: Tried some things. Created a hidden field which i update based on the clicks from the controls. If the value of the field falls in a value that i define then i load the dialog on page_load , if not then it doesnt show. this works , but i am having problem with the edit/insert in the listview in the dialog...seems that it doesnt work...
Since a postback is required after you load the details in the listview, you need to spit out javascript code during the postback that will put the listview into a jquery dialog.
One way is this:
<div id="dialogHolder"><!-- this is just a div enclosing the listview -->
<asp:listview runat="server"...
</div>
Now, when you do the postback to populate the listview with the details, do this:
private void populateListView()//
{
//code to populate listview above
Page.ClientScript.RegisterStartupScript(this.GetType(),"dialogscript","$('#dialogHolder').dialog('open');",true);
}
What i have found to work up to know is this:
if ($("#cphMain_HiddenField1").val() == "dlg") {
$("#divTodo_Details").dialog({ show: 'fade', hide: 'fade', autoOpen: true, modal: true, title: "Details", width: 1024 });
}
//
$(".showdetails").click(function () {
$("#cphMain_HiddenField1").val("dlg");
});
//
$(".NOshowdetails").click(function () {
$("#cphMain_HiddenField1").val("");
});
In my aspx markup i give the class showdetails and NOshowdetails to whatever controls i want so during the postback the dialog appears only on the controls i want.
p.s. i also have a hiddenfield to hold the value which i am checking on page_load.
What is the preferred method to change the visibility property of a .NET Ajax Control Toolkit CascadingDropDown control? I would like to render the control "invisible" when a null value is returned from a query.
It appears that "OnSelectedIndexChanged" event does not fire from the <asp:DropDownList> when using the toolkit extender.
Honestly, I would just target the DropDownList that the CascadingDropDownExtender is attached to with the display:none css style. You could do this in javascript on the page like this:
<script type="text/javascript">
function hideDDL(){
// Get the DropDownList by its ID value
var ddl = document.getElementById("<%= myDropDownList.ClientID %>");
// If there are no items in the drop down, hide it
if (ddl.options.length == 0)
ddl.style.display = "none";
}
</script>
And then, in your DropDownList markup, just add the function above to the client-side onchange event:
<asp:DropDownList runat="server" ID="myDropDownList" onchange="hideDDL();" ... >
...
</asp:DropDownList>
Note: Obviously, you will want logic in the javascript function to indicate whether or not the DropDownList should be hidden (such as checking to see if the control has no elements to select, etc). If you have trouble with that, let me know and I can try and help with that too.
EDIT: I have added a possible example of said logic =)
I have a textbox1 and button1 and panel1 (which is used as a popup control)
i want if textbox1.text="show" then modalpopup control whose id is panel1 will be visible on buttonclick event other wise .... modal popup control panel1 will not be shown ...
how to do this ? using vb.net ?
Use Javascript's getElementById method to determine if the text has that specific value and then call showPopup() if you want to.
function showPopup() {
var modalPopupBehavior = $find('programmaticModalPopupBehavior');
modalPopupBehavior.show();
}
function hidepopup() {
var modalPopupBehavior = $find('programmaticModalPopupBehavior');
modalPopupBehavior.hide();
}
I know you stated, you want to do this in vb.net, but then you're at server-side and it is far easier to deal with this on client-side if you don't have something not to.
Here's how you do in code-behind. Add this to your button click event:
If TextBox1.Text = "something" Then
ModalPopupExtender1.Show()
Else
ModalPopupExtender1.Hide()
End If
I have a lot of data to display in a GridView. Because there's so much information per row, I'd like to be able to display additional information when a user clicks on the row, so I thought a PopupExtender from the AJAX Toolkit would be perfect.
Ideally, I want the popup to display whenever any of the controls within the row are selected. I've been able to successfully attach the PopupExtender to a single control within the row, but I can't get the pop-up to attach to the row itself.
I would have thought that setting the PopupExtender's TargetControlId to the Row's ClientID within the RowDataBound event would work, but when I do this I get a runtime error:
TargetControlID of 'popupExtId' is not valid.
A control with ID 'gvList_ctl02' could not be found.
I noticed that the GridViewRow is rendered, the tr element does not include an id, so I also tried extending the GridView control to override the CreateRow method to render the id - using this method I was able to render the row's ID (e.g. gvList_ctl02), but the same runtime error was thrown when I added the PopupExtender back into the code.
I also tried binding the showPopup() javascript command to the row's onclick event to get the popup to display manually; whilst the click event is registered OK and is definitely triggered, the popup is still not shown.
Does anyone have any idea how to / if you can bind a PopupExtender to a GridViewRow?
My row bound code is as follows:
protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Bind the popup extender's target ID to the row ID
// This will cause a runtime error
PopupControlExtender pop = e.Row.FindControl("popupExtId") as PopupControlExtender;
pop.TargetControlID = e.Row.ClientID;
// Also bind the client side click handler to try to get the popup to show
// The alert is triggered and no javascript error is generated, but the popup does not display
e.Row.Attributes.Add("onclick", "alert('Row Clicked'); $find('" + pop.BehaviorID + "').showPopup();");
}
}
Many thanks.
If you're not opposed to using an ajax ModalPopupExtender, I use a little bit of javascript and some sneaky hidden button clicks to fire off my modal popups from within a grid view. I usually make my modal popup extender's target control id my hidden button, then, via javascript, fire my hidden button's click event to show the modal popup.
Here's my modal popup and hidden button markup.
<asp:Button ID="hiddenButton" runat="server" Text="" style="display:none"></asp:Button>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender2" runat="server"
TargetControlID="hiddenButton" PopupControlID="Panel1" CancelControlID="CancelButton"
BackgroundCssClass="modalBackground" Drag="True"/>
Here's my javascript to show my popup.
function showModal(btnID) {
btn = document.getElementById(btnID);
btn.click();
}
In my rowdatabound event, I call the javascript function showModal from button's onclick event.
Button myButton = (Button)e.Row.Cells[9].Controls[1];
matchButton.Attributes.Add("onclick", "showModal('" + hiddenButton.ClientID + "');");
Hope this might help point you in the right direction.