Seems like a simple thing to do, but not sure how to do it.
I have this ReadOnly textbox and it gets populated when the user clicks on a button and selects a value from a modal box. I need an other image_click that will clear the text box. Given below is the code I have, not sure how to have a simple image button click to do this.
The Html.SecurityTrimmedActionButton for the 'SearchButton' works fine. The problem I have is with the 'DeleteButton'. Do I need to have even the SecurityTrimmedAction here, since I really do not need to call any controller, I have the function to clear the textbox in the view itself. What can I use instead of the Html.SecurityTrimmedAction?
<%: Html.TextBoxFor_Readonly(model => model.AdditionalEmailsSentTo, new { style = "width:500px; height:40px;" })%>
<%: Html.SecurityTrimmedActionButton(true, "Search Active Directory", "Index", "ActiveDirectory", "btnAdditionalEmailSearch", "clsSearchButton")%>
<%: Html.SecurityTrimmedActionButton(true, "Clear AdditionalEmails", "Index", "ActiveDirectory", "btnRemoveAdditionalEmail", "clsDeleteButton")%>
Here is my script to clear the textbox
$("#btnRemoveAdditionalEmail").click(function (event) {
event.preventDefault();
$("#AdditionalEmailsSentTo").val("");
});
When clicked on the image, the entire text box along with the image buttons disappear.
Here is how it was resolved
<div class="editor-label">
<%: Html.Label("Additional Email Address") %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor_Readonly(model => model.AdditionalEmailsSentTo, new {id="AdditionalEmailsSentTo", style = "width:500px; height:40px;" })%>
<%: Html.SecurityTrimmedActionButton(true, "Search Active Directory", "Index", "ActiveDirectory", "btnAdditionalEmailSearch", "clsSearchButton")%>
<button id='btnRemoveAdditionalEmailSearch' class='clsRemoveButton'>
Clear Additional Emails</button>
</div>
Here is my javascript function
$("#btnRemoveAdditionalEmailSearch").click(function (event) {
event.preventDefault();
$("#AdditionalEmailsSentTo").val("");
});
and the textbox was disappering because, I did not notice that the button clsDeleteButton was hooked to do that. A collegue discovered that and created an other one called clsRemoveButton.