Wednesday, March 28, 2012

Updating a Text Box after the modalpopup closes.

Hi There

I'm attempting to create a function for users that allows them to browse their intranet site and save links within the intranet as a collection of 'my links'. To do this I'm using an iFrame embedded within the modalpopup extension. Everything is working with the exception of the final part (which is quite frustrating) - Basically I need to populate a textbox with the current location in the iFrame. I know that I'm ready the value correctly but the text box is just not updating. I've inserted the user control below - all you need to do is insert the control into a new page and then point the iframe at a starting page. Any help greatly appreciated as I could do with an answer to this issue as soon as possible.

<%@dotnet.itags.org. Control Language="C#" AutoEventWireup="true" CodeFile="test.ascx.cs" Inherits="includes_mylinks" %>
<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<script type="text/javascript">
function onOk() {
var NewURLTextBox = parent.document.getElementById("<%= newurl.UniqueID %>");
var NavFrame = parent.frames(0);
NewURLTextBox.InnerText = NavFrame.location.href;
NewURLTextBox.InnerHTML = NavFrame.location.href;
NewURLTextBox.Value = NavFrame.location.href;
alert(NavFrame.location.href);
}
</script>
<asp:ScriptManager runat="Server" EnablePartialRendering="true" ID="ScriptManager" />
<h3>Add a new link</h3>
<table width="100%">
<tr>
<td style="width: 100px">Title:<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="newurldescription"
ErrorMessage="Please supply a Title" SetFocusOnError="True" ValidationGroup="NewURL">*</asp:RequiredFieldValidator>
</td>
<td><asp:TextBox runat="server" Text ="" ID="newurldescription" /></td>
</tr>
<tr>
<td>Address:<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="newurl"
ErrorMessage="Please specify the URL you wish to save" SetFocusOnError="True" ValidationGroup="NewURL">*</asp:RequiredFieldValidator>
</td>
<td><asp:TextBox runat="server" ID="newurl" EnableViewState="false" /> <asp:LinkButton ID="cmdBrowse"
runat="server">[Browse]</asp:LinkButton></td>
</tr>
<tr>
<td>Position:<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="newurlposition"
ErrorMessage="Please enter a value between 1 and 9" MaximumValue="9" MinimumValue="1"
SetFocusOnError="True" Type="Integer" ValidationGroup="NewURL">*</asp:RangeValidator>
</td>
<td><asp:TextBox runat="server" Text ="" ID="newurlposition" MaxLength="1" Width="15px" /></td>
</tr>
</table>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<asp:Panel ID="BrowsePanel" runat="server">
<asp:Panel ID="Panel3" runat="server" Style="cursor: move;background-color:#DDDDDD;border:solid 1px Gray;color:Black">
<div>
<p>Navigate to the Page that you would like to add to My Links:</p>
</div>
</asp:Panel>
<iframe id="BrowseIntranet" runat="server" src="http://pics.10026.com/?src=default.aspx" height="450px" width="850px" ></iframe>
<p style="text-align: center;">
<asp:Button ID="OkButton" runat="server" Text="Select" />
<asp:Button ID="CancelButton" runat="server" Text="Cancel" />
</p>
</asp:Panel>
<cc1:ModalPopupExtender ID="ModalPopupExtender" runat="server"
TargetControlID="cmdBrowse"
PopupControlID="BrowsePanel"
BackgroundCssClass="modalBackground"
OkControlID="OkButton"
OnOkScript="onOk()"
CancelControlID="CancelButton"
DropShadow="false"
PopupDragHandleControlID="Panel3" />

Hi,

I was searching for somethig, but came across your post. I read an artcle to update the server control on postback. the url ishttp://www.aspdotnetcodes.com/ModalPopup_Postback.aspx . in this article they make use of label control, please try it with your TextBox.. and let me know if if helps you.

Thanks

No comments:

Post a Comment