Accessing a Text Box in a modalPopup

uconnfb13
uconnfb13 used Ask the Experts™
on
Hi All,

I have used the Ajax Tool Kit extenders to create a popup for my web page.  I would like this popup to take in a date and then on the click of a button insert that date into a table.

My popup is a panel with a text box and a asp button inside of it.  I would like to click on the button and insert the date from popup into my database.  However, when I click on my button it tells me that the field inside of the popup does not exist.  Does anybody know how to (in C# at the server) reference a textbox inside of a popup?

Thanks a lot,

The pertinent C# function.  Dater is the field that I would like to reference but I am not able to.
    protected void InsertHol(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection("Data Source=****-PC\\SQLEXPRESS;Initial Catalog=ref_def;Integrated Security=True");
        String sqlstr;
        conn.Open();
        string strParentID;
        strParentID = (string)(Session["LastSchoolID"]).ToString();

      

        sqlstr = "insert into ls_school_holiday values ('";
        sqlstr = sqlstr + dater.Text.Trim();
        sqlstr = sqlstr + ", '" + strParentID;
        sqlstr = sqlstr + ", '" + last.Text.Trim();
        sqlstr = sqlstr + "','True','True','Tom Randazza',getdate(),getdate(),'',getdate(),'2099-12-31')";
     
        SqlCommand InsertFran = new SqlCommand(sqlstr, conn);
        InsertFran.ExecuteNonQuery();
    }

Open in new window


The pertinent section of html/asp/ajax:

<%@ Page Language="C#" Debug="true" AutoEventWireup="true" CodeFile="school_form_2.aspx.cs" Inherits="school_form_2" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">

<title>Extra School Information</title>

<link href="styles.css" rel="stylesheet" type="text/css" media="screen" />
        
        
 
        
        
        <style type="text/css">
            #Button1
            {
                text-align: left;
                width: 99px;
            }
            .style4241
            {
                text-align: left;
                font-weight: bold;
                text-decoration: underline;
                font-size: x-large;
                height: 29px;
                width: 286px;
            }
            .style4243
            {
                text-align: right;
                height: 29px;
                }
            .style4246
            {
                height: 278px;
            }
            #Button3
            {
                text-align: center;
                width: 99px;
            }
            #Button4
            {
                text-align: center;
                width: 99px;
            }
            #Button5
            {
                width: 99px;
            }
            .bottom
            {
                text-align: center;
            }
            #Button6
            {
                width: 99px;
            }
            .style43333283
            {
                height: 29px;
                }
            .style43333286
            {
                height: 15px;
                font-size: 10pt;
                text-align: right;
            }
            #Text2
            {
                width: 312px;
            }
            #Text1
            {
                width: 322px;
            }
            #Text3
            {
                width: 76px;
            }
            #Text4
            {
                width: 157px;
            }
            #Text5
            {
                width: 309px;
            }
            #Text6
            {
                width: 94px;
            }
            #Select1
            {
                width: 65px;
                height: 16px;
            }
            #Text6
            {
                width: 150px;
            }
            .styled43333284
            {
                text-align: right;
            }
            .styledd43333284
            {
                text-align: right;
            }
            #Text7
            {
                width: 100px;
            }
            #Text9
            {
                width: 60px;
            }
            #Text11
            {
                width: 60px;
            }
            #Text8
            {
                width: 130px;
            }
            #Text10
            {
                width: 129px;
            }
            #Text12
            {
                width: 321px;
            }
            #Text13
            {
                width: 216px;
            }
            #Text14
            {
                width: 203px;
            }
            #Text15
            {
                width: 77px;
            }
            #Text16
            {
                width: 145px;
            }
            .styledd43333285
            {
                text-align: right;
            }
            #Text17
            {
                width: 93px;
            }
            #Text18
            {
                width: 200px;
            }
            #Button7
            {
                width: 99px;
            }
            #Button8
            {
                width: 99px;
            }
            #Button9
            {
                width: 99px;
            }
            #Button9
            {
                width: 99px;
            }
            #Text18
            {
                width: 220px;
            }
            #Button10
            {
                width: 99px;
                height: 22px;
                font-weight: 700;
            }
            #Text19
            {
                width: 303px;
            }
            #Text20
            {
                width: 300px;
            }
            #Text21
            {
                width: 160px;
            }
            #Text18
            {
                width: 130px;
            }
            #Text19
            {
                width: 60px;
            }
            #Text20
            {
                width: 321px;
            }
            #Text21
            {
                width: 308px;
            }
            #Text22
            {
                width: 178px;
            }
            #Text23
            {
                width: 178px;
            }
            .style43333292
            {
                font-size: 10pt;
                text-align: right;
            }
            .style43333296
            {
                height: 15px;
                font-size: 12pt;
                text-align: left;
                width: 223px;
                font-weight: 700;
                text-decoration: underline;
            }
            .style43333297
            {
                font-size: 10pt;
                text-align: right;
                width: 418px;
            }
            #Text24
            {
                width: 309px;
            }
            #Text24
            {
                width: 312px;
            }
            #Button11
            {
                width: 99px;
            }
            #Text25
            {
                width: 312px;
            }
            #Text26
            {
                width: 178px;
            }
            #Text27
            {
                width: 93px;
            }
            #Text27
            {
                width: 178px;
            }
            #Text28
            {
                width: 93px;
            }
            #Text28
            {
                width: 178px;
            }
            #Text29
            {
                width: 93px;
            }
            #Text29
            {
                width: 178px;
            }
            #Text30
            {
                width: 178px;
            }
            #Text31
            {
                width: 178px;
            }
            #Text32
            {
                width: 178px;
            }
            #Text41
            {
                width: 100px;
            }
            #Text54
            {
                width: 100px;
            }
            #Select2
            {
                width: 100px;
            }
            #Select3
            {
                width: 100px;
            }
            .style43333299
            {
                font-size: 10pt;
                text-align: right;
            }
            .style43333300
            {
                font-size: 10pt;
            }
            #Text58
            {
                width: 309px;
            }
            #Text58
            {
                width: 312px;
            }
            .style43333301
            {
                text-align: right;
                font-size: 7.44508e+015;
            }
            .style43333303
            {
                font-size: 7.44508e+015;
            }
            .style43333304
            {
                text-align: right;
                font-size: 10pt;
            }
            .style43333305
            {
                height: 278px;
                width: 422px;
            }
            .style43333306
            {
                font-weight: bold;
                font-size: 12pt;
                text-decoration: underline;
            }
            .ModalWindow
            {
                margin-top: 74px;
            }
            #frame1
            {
                height: 231px;
            }
            .style43333307
            {
                width: 313px;
                text-align: center;
            }
            .style43333308
            {
                width: 313px;
                font-weight: bold;
                text-decoration: underline;
                font-size: large;
                text-align: center;
            }
            .style43333309
            {
                width: 150px;
            }
            .style43333310
            {
                width: 264px;
            }
            #Button3
            {
                text-align: left;
                width: 99px;
            }
            #Button5
            {
                text-align: center;
                width: 99px;
            }
            #Button6
            {
                text-align: center;
                width: 99px;
            }
            #Button6
            {
                text-align: left;
                width: 99px;
            }
            </style>
        
     <script type='text/javascript'>
         function showPop() {
             $find('Home3_ModalPopupExtender').hide();
             onload();
         }
         function showPop2() {
             $find('AddHol_ModalPopupExtender').hide();
             onload();
         }
       
          </script>   
        
        
 
</head>
<body>
    <form id="form1" runat="server">  
    <div style="width:940px; margin: 0 auto;"><img alt="" src="top2.png" /></div>
    <div id="border">    
    <div id="wrapper">
    
    <hr style="display:none" />

    <!-- ###################### END OF GRC MASTHEAD MENU  ###################### -->

	<!-- end #menu -->	    
    
	<!-- end #header -->
    <div id="content_table" align=center>
				
		</div>
				
				<table align="center" style= "border: thin none #FFFFFF; width: 865px; padding-right: 2px; height: 50px;">
			<tr><td class="style43333283">
                <img alt="" src="AllPrograms_nb_vFinal.gif" 
                    style="height: 65px; width: 67px; text-align: center;" 
                    class="style43333275" /></td>
                <td class="style43333300">
                    &nbsp;</td>
                <td class="style4241" colspan="2">Extra School Info.: <asp:SqlDataSource 
                        ID="ExtraInfo" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ref_defConnectionString %>" 
                        SelectCommand="select ls_school_x.*,ls_school.name from ls_school_x 
left outer join ls_school
on ls_school.row_id=ls_school_x.school_id
">
                    </asp:SqlDataSource>
               
                    <asp:ScriptManager ID="ScriptManager1" runat="server">
                    </asp:ScriptManager>
                    <asp:SqlDataSource ID="SchoolHol" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ref_defConnectionString %>" 
                        
                        SelectCommand="SELECT * FROM [LS_SCHOOL_HOLIDAY] WHERE (([SCHOOL_ID] = @SCHOOL_ID) AND ([ACTIVE_FLG] = @ACTIVE_FLG))">
                        <SelectParameters>
                            <asp:SessionParameter Name="SCHOOL_ID" SessionField="LastSchoolId" 
                                Type="Int64" />
                            <asp:Parameter DefaultValue="True" Name="ACTIVE_FLG" Type="Boolean" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </td>
                <td class="style4243">
                    &nbsp;&nbsp;
                    <asp:Button ID="Home1" runat="server" Text="Home" OnClick="navHome" BorderColor="Navy" 
                        Font-Bold="True" Font-Names="Verdana" ForeColor="#000066" Width="85px" 
                        Height="21px" style="text-align: center" />
&nbsp;&nbsp;
                    <asp:Button ID="list" runat="server" Text="List" OnClick="navList" BorderColor="Navy" 
                        Font-Bold="True" Font-Names="Verdana" ForeColor="#000066" Width="85px" 
                        Height="21px" style="text-align: center" />
&nbsp;&nbsp;
                    <asp:Button ID="Home3" runat="server"  Text="Record Info" OnClick="recordInfo" BorderColor="Navy" 
                        Font-Bold="True" Font-Names="Verdana" ForeColor="#000066" Width="97px" 
                        Height="21px" style="text-align: center" Enabled="True" />
              
                    <cc1:ModalPopupExtender ID="Home3_ModalPopupExtender" runat="server" Popupcontrolid="panopen"
                        DynamicServicePath="" Enabled="True" TargetControlID="Home3"  BackgroundCssClass="modalBackground" 
                        oncancelscript="reff()" CancelControlID="" X="750" Y="150">
                    </cc1:ModalPopupExtender>
              
&nbsp;&nbsp;
                    <asp:Button ID="Home4" runat="server" Text="Save" OnClick="datasql" BorderColor="Navy" 
                        Font-Bold="True" Font-Names="Verdana" ForeColor="#000066" Width="88px" 
                        Height="19px" style="text-align: center" Enabled="True" />
                </td>
                </tr>
			
			</table>	
			<table align="center" style= "border: thin none #FFFFFF; width: 865px; padding-right: 2px;">
			
			<tr><td class="style43333297" colspan="2">
                </td>
                <td class="style43333292" colspan="5">
                </td>
                </tr>
			
			<tr><td class="style43333292">
                &nbsp;Name:
                </td>
                <td class="style43333313">
                    <asp:TextBox ID="school_name" runat="server" Width="312px" 
                        ></asp:TextBox>
                </td>
                <td class="style43333299">
                    Day Start: </td>
                <td class="style43333315">
                    <asp:TextBox ID="start" runat="server" Width="80px" ></asp:TextBox>
                </td>
                <td class="style43333292" colspan="2">
                    Day End:</td>
                <td class="style4333328f6">
                    <asp:TextBox ID="end" runat="server" Width="80px" 
                        ></asp:TextBox>
                </td>
                </tr>
			
			<tr><td class="style43333292">
                ID:</td>
                <td class="style43333313">
                    <asp:TextBox ID="theSchool" runat="server" Width="312px" 
                        ></asp:TextBox>
                </td>
                <td class="st3333314">
                    <font size="2" style="text-align: right">Year Start:</td>
                <td class="style43333315">
                    </font>
                    <asp:TextBox ID="yr_start" runat="server" Width="80px" 
                        ></asp:TextBox>
                </td>
                <td class="style43333292" colspan="2">
                    Year End:</td>
                <td class="style43333300">
                    <asp:TextBox ID="yr_end" runat="server" Width="80px" 
                        ></asp:TextBox>
                </td>
                </tr>
			
			<tr><td class="style43333292">
                # Student Units</td>
                <td class="style43333313">
                    <asp:TextBox ID="students" runat="server" Width="80px" ></asp:TextBox>
                </td>
                <td class="style43333304">
                    Half Day:</td>
                <td class="styldde43333301" colspan="2">
                    <asp:CheckBox ID="half" runat="server" />
                </td>
                <td class="style43333301">
                    <font size="2" style="text-align: right">Part Time:</td>
                <td class="style43333311">
                    </font><span class="style43333303">
                    </font>
                    <asp:CheckBox ID="partc" runat="server" />
                    </span>
                    </td>
                </tr>
			
			<tr><td class="style43333292">
                # Classrooms:</td>
                <td class="style43333313">
                    <asp:TextBox ID="classrooms" runat="server" Width="80px" 
                        ></asp:TextBox>
                </td>
                <td class="style43333314">
                    &nbsp;</td>
                <td class="style43333311" colspan="4">
                    &nbsp;</td>
                </tr>
			
			</table>
			<table align="center" 
            style= "border: thin none #FFFFFF; width: 865px; padding-right: 2px; margin-left: 15px;">
			<tr><td class="style43333296" colspan="2">
                </td>
                <td class="style43333286">
                    <asp:Button ID="Home0" runat="server" Text="Previous" BorderColor="Navy" 
                        Font-Bold="True" Font-Names="Verdana" ForeColor="#000066" Width="115px" OnClick="previous_record" />
                    &nbsp;&nbsp;&nbsp;
                    <asp:Button ID="Home" runat="server" Text="Next" OnClick="next_record" BorderColor="Navy" 
                        Font-Bold="True" Font-Names="Verdana" ForeColor="#000066" Width="115px" />
                    </td>
                </tr>
			
			<tr><td class="style43333296" colspan="2">
                Holidays:</td>
                <td class="style43333306">
                    </td>
                </tr>
			
<tr>
                <td class="style43333305" 
                    style="border: thin none #000080; horizontal: middle;" valign="top">
                    <asp:GridView ID="Headers" 
                        runat="server" AllowPaging="True" 
                        AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SchoolHol" 
                        Height="30px" Width="327px" EnableViewState="False">
                        <Columns>
                           
                          <asp:TemplateField> 
                            <ItemTemplate> 
                                <asp:CheckBox runat="server" ID="chkYourCheckBoxField" /> 
                            </ItemTemplate> 
                         </asp:TemplateField> 
                            <asp:BoundField DataField="ROW_ID" HeaderText="ROW_ID" 
                                SortExpression="ROW_ID" InsertVisible="False" ReadOnly="True" />
                            <asp:BoundField DataField="HOLIDAY_DT" HeaderText="HOLIDAY_DT" 
                                SortExpression="HOLIDAY_DT" />
                        </Columns>
                        <HeaderStyle BackColor="#000066" ForeColor="#FFFF66" />
                        <AlternatingRowStyle BackColor="#FFFF66" />
                    </asp:GridView>
                    <asp:Button ID="Home9" runat="server" Text="Delete Selected" BorderColor="Navy" 
                        Font-Bold="True" Font-Names="Verdana" ForeColor="#000066" Width="142px" 
                        OnClick="deleteSchools" />
                    &nbsp;&nbsp;
                    <asp:Button ID="AddHol" runat="server" Text="Add Holiday" BorderColor="Navy" 
                        Font-Bold="True" Font-Names="Verdana" ForeColor="#000066" Width="115px" 
                        OnClick="deleteSchools" />
                    <cc1:ModalPopupExtender ID="AddHol_ModalPopupExtender" runat="server" Popupcontrolid="Panel1"
                        DynamicServicePath="" Enabled="True" TargetControlID="AddHol">
                    </cc1:ModalPopupExtender>
                    </td>
                <td class="style4246" colspan="2" style="border: thin none #000080" 
                    valign="top">
                    &nbsp;</td>
    </tr>
   
    </table>
    <asp:Panel ID="panOpen" runat="server" Height="271px" Width="333px" 
            CssClass="ModalWindow" Wrap="False">
  <IFRAME id="frame1" src="record_info.aspx" Scrolling="no" bordercolor="#000066" frameborder="yes" 
                            contenteditable="false" runat="server">

</IFRAME>

<table align="center"><tr><td style="text-align: left"><input ID="Button2" 
        onclick="showPop()" type="button" value="Close" 
        style="border: thin solid #000080; font-weight: bold; color: #000080" /></td></tr></table>   
</asp:Panel>
		</br>
		 
		 <asp:Panel ID="Panel1" runat="server" Height="271px" Width="430px" 
            CssClass="ModalWindow" Wrap="False">


<table align="center" bgcolor="White" bordercolor="#000066" 
                 style="border: medium solid #000080"><tr>
        <td class="style43333308" colspan="2">Add Holiday</td></tr>
    <tr>
        <td style="text-align: center" class="style43333309">
            &nbsp;</td>
        <td class="style43333310" style="text-align: center">
            &nbsp;</td>
    </tr>
    <tr>
        <td style="text-align: right; font-weight: 700;" class="style43333309">
            Date:</td>
        <td class="style43333307" style="text-align: left">
            <asp:TextBox ID="Dater" runat="server" Width="231px"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td style="text-align: center" class="style43333307" colspan="2">
            &nbsp;</td>
    </tr>
    <tr>
        <td class="style43333307" colspan="2">
            <asp:Button ID="Button5" runat="server" OnClick="InsertHol" Text="Add Holiday" />
            &nbsp;&nbsp;
            <input ID="Button6" onclick="showPop2()" 
                style="border: thin solid #000080; font-weight: bold; color: #000080" 
                type="button" value="Close" /></td>
    </tr>
    <tr>
        <td style="text-align: center" class="style43333309">
            &nbsp;
            </td>
    </tr>
             </table>   
</asp:Panel>
	<!-- end #wrapper -->
	
	</div>
	<!-- end #border -->		
	<div style="width:940px; margin: 0 auto;"><img alt="" src="bottom2.png" /></div>
    </form>
</body>
</html>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I think it's just because it's case-sensitive, try changing "dater" to "Dater".

Author

Commented:
Thank you!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial