|
-
Mar 4th, 2009, 02:59 AM
#2
Junior Member
Re: [2008] Accessing hidden field in AJAX modalPopup
Hi,
You want to display the value in the hidden field inside a text box using a modalPopup. I have some code here that does just that. Open up an Ajax enabled web site in VS 2005 and just copy the code I give below for Default.aspx and Default.aspx.cs. There is a hidden field called myVars containing the value "1,2,3,4,5,6" in this page. When you run the application a link with text "View hidden field" will appear. Just click on this and the hidden field value will appear in a text box with an ok and a cancel button in a modal popup.
Code for Default.aspx
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" cancelcontrolid="CancelButton" dropshadow="true" okcontrolid="OkButton"
PopupControlID="Panel1" targetcontrolid="mylink">
</cc1:ModalPopupExtender>
<asp:LinkButton PostBackUrl="#" ID="mylink" runat="server" Text="View Hidden fields" />
<asp:Panel ID="panel1" runat="server">
<asp:TextBox EnableViewState="true" ID="mytextbox" runat="server" Text="This is fine" OnLoad="mytextbox_Load"></asp:TextBox>
<asp:Button ID="CancelButton" runat="server" Text="Cancel" />
<asp:Button ID="OkButton" runat="server" Text="OK" />
<asp:HiddenField Value="1,2,3,4,5,6" ID="myVars" runat="server" />
</asp:Panel>
</div>
</form>
</body>
</html>
Code for Default.aspx.cs
Code:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void mytextbox_Load(object sender, EventArgs e)
{
mytextbox.Text = myVars.Value;
}
}
Hope this helps.
Warm Regards ,
sr_jay.
 Originally Posted by Ms.Longstocking
I guess this thread can be here or in a more AJAXy forum....
Say I populate a hiddenfield:
<asp:HiddenField ID="myVars" runat="server" />
value = 4,6,2,7,4,6,3,5,8,9 (it's a string of digits separated by commas)
...using javascript.
Then, using AJAX's ModalPopupExtender, I wish to show the values in this hidden field in a modal popup.
How exactly would I go about doing this? I've been having issues accessing the hiddenfield.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|