jeudi 6 août 2015

how to run method after check box is checked

I am building a form on an aspx page. I want to run a method that will add more fields and labels if the user ticks a checkbox labeled 'recurring donation?'

My Form

        <telerik:LayoutRow CssClass="formContainer">
            <Columns>
                <telerik:LayoutColumn Span="12" SpanSm="12" SpanMd="12">
                    <asp:Label id="firstName" runat="server"></asp:Label>
                    <br />
                    <asp:TextBox runat="server" ID="UserFirstName"></asp:TextBox>
                </telerik:LayoutColumn>
                <telerik:LayoutColumn Span="12" SpanSm="12" SpanMd="12">
                    <asp:Label id="lastName" runat="server"></asp:Label>
                    <br />
                    <asp:TextBox runat="server" ID="UserLastName"></asp:TextBox>
                </telerik:LayoutColumn>
                <telerik:LayoutColumn Span="3" SpanSm="12" SpanMd="12">
                    <asp:Label id="address1" runat="server"></asp:Label>
                    <br />
                    <asp:TextBox runat="server" ID="userAddress1"></asp:TextBox>
                </telerik:LayoutColumn>
                <telerik:LayoutColumn Span="9" SpanSm="12" SpanMd="12">
                    <asp:Label id="address2" runat="server"></asp:Label>
                    <br />
                    <asp:TextBox runat="server" ID="userAddress2"></asp:TextBox>
                </telerik:LayoutColumn>
                <telerik:LayoutColumn Span="3" SpanMd="12" SpanSm="12">
                    <asp:Label ID="city" runat="server"></asp:Label>
                    <br />
                    <asp:TextBox runat="server" ID="userCity"></asp:TextBox>
                </telerik:LayoutColumn>
                <telerik:LayoutColumn Span="9" SpanMd="12" SpanSm="12">
                    <asp:Label ID="zip" runat="server"></asp:Label> 
                    <br />
                    <asp:TextBox ID="userZip" runat="server"></asp:TextBox>
                </telerik:LayoutColumn>
                <telerik:LayoutColumn>
                    <asp:Label ID="returningDonor" runat="server"></asp:Label>
                    <br />
                    <asp:CheckBox ID="userReturningDonor" runat="server" />
                </telerik:LayoutColumn>
            </Columns>
        </telerik:LayoutRow>

And my code behind

public partial class donationForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        firstName.Text = "First Name";
        lastName.Text = "Last Name";
        address1.Text = "Address 1";
        address2.Text = "Address 2";
        city.Text = "City";
        zip.Text = "Zip Code";
        returningDonor.Text = "Recurring Donation?";

        userReturningDonor.Checked = showRecuring();
    }
    static void showRecuring()
    {
        /*RUN CODE*/
    }
}

The error im getting is

Cannot implicity convert type 'void' to 'bool'




Aucun commentaire:

Enregistrer un commentaire