Archive

Monthly Archives: April 2010

There is interesting trick to catch ASPX runat=”server” controls by jQuery selector on client side:

<asp:DropDownList id=”ddlFirst” runat=”server”>
</asp:DropDownList>

jQuery(‘select[id$=ddlFirst]’).val();

Regular jQuery(‘#ddlFirst’) doesn’t work because on client side ASPX used ClienID like ‘Something_ddlFirst’ instead of ‘ddlFirst’.

So, there is possible to treat regular ASP Panel as modal popup dialog. And even use that one as confirmation dialog instead of standard JS confirm().
I think it’s ok to use standard one in almost all case.
But if it needs custom one like in today case, then it may be used like this below.
Also, there is standard OnClienClick=”” (means regual onclick=””) to do the same but mach more easy and faster.

// ModalPopupExtender and ConfirmButtonExtender

<%– Delete Confirmation Popup Panel –%>
<asp:Panel ID=”pnlDelConfirm” runat=”server”>
Are you sure you want to delete this game?
<asp:LinkButton ID=”btnDelConfirmDelete” runat=”server” Text=”Delete” />
<asp:LinkButton ID=”btnDelConfirmCancel” runat=”server” Text=”Cancel” />
</asp:Panel>

<%–
Button. We trigger confirmation on this button action.
Standard OnClientClick is used when page is still loading to provide regular JS confirm instrad of our custom ModelPopup
–%>
<asp:Button ID=”btnDelete” runat=”server” Text=”Delete” CommandName=”Delete” CausesValidation=”true”
OnClientClick=”return confirm(‘Are you sure you want to delete this game?’);” />

<atk:ConfirmButtonExtender ID=”ConfirmButtonExtender1″ runat=”server”
TargetControlID=”btnDelete” DisplayModalPopupID=”mdlDelConfirm”>
</atk:ConfirmButtonExtender>

<atk:ModalPopupExtender ID=”mdlDelConfirm” runat=”server” TargetControlID=”btnDelete”
BackgroundCssClass=”modalBackground” PopupControlID=”pnlDelConfirm” OkControlID=”btnDelConfirmDelete” CancelControlID=”btnDelConfirmCancel”>
</atk:ModalPopupExtender>

So, there is Django 1.2 in action for now.
First one of improvements I used smart if tag embedded right into Django templates.
I use special custom smart if tag before.

For now it support such cool things like <=, !=, and or not
but it really can’t be used because it doesn’t support parenthesis.
I need to use nested if’s or put that logic to controller layer.
Such things make Django sucks. 😦