- The result needed to only display the users name
- The ID of the contact needed to be saved
- The label needs to be able to send the value back to the server, but prevent people from editing the label
1 2 3 4 5 6 7 8 9 | < asp:TextBox ID = "txtContact" onfocus = "focusCtrl('btnContact', event);" runat = "server" ></ asp:TextBox > < asp:TextBox ID = "txtContactID" style = "display: none;" runat = "server" ></ asp:TextBox > < asp:Button ID = "btnContact" OnClientClick = "return contactPicker('txtContactID', 'txtContact');" Text = "Select" CausesValidation = "false" runat = "server" ></ asp:Button > < asp:RequiredFieldValidator ID = "rfvContact" ControlToValidate = "txtContact" ErrorMessage = "Contact is required" ValidationGroup = "Required" Display = "Dynamic" InitialValue = "" CssClass = "ms-error" EnableClientScript = "false" runat = "server" > < img alt = "Validation Error" title = "Contact is required" src = "/_layouts/images/EXCLAIM.GIF" /> </ asp:RequiredFieldValidator > < script type = "text/javascript" > $(function () { focusCtrl('btnContact'); }); </ script > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | function focusCtrl(ctlID, e) { var ctl = $( 'input[id$=\'' + ctlID + '\']' ); e = e || window.event; var t = (e) ? e.target || e.srcElement : null ; if (ctl.length > 0) { ctl.focus(); if (t != null ) { ctl.click(); } } else if (e || window.event) { $(t).blur(); //Focus next textbox //$(t).next("input:not(input[type='submit']):visible").focus(); } return false ; } function contactPicker(txtID, txtLabel) { var options = { url: '../Contacts/ContactPicker.aspx' , title: 'Contact Picker' , allowMaximize: true , showClose: true , showMaximized: false , dialogReturnValueCallback: function (dialogResult, returnValue) { if (dialogResult == SP.UI.DialogResult.OK) { var ret = unescape(returnValue), name = ret.split( ";#" )[1]; $( "input[id$='" + txtName + "']" ).val(name); $( "input[id$='" + txtID + "']" ).val(ret); } } }; SP.UI.ModalDialog.showModalDialog(options); return false ; } |
No comments:
Post a Comment