Compiler Error Message: CS1061 ASPX
<p>I am trying to code a drop down list that will have an <code>OnSelectedIndexChanged</code> event but i can't make it work.</p><p>So here's the code on my .aspx</p><pre><br /><code><asp:DropDownList ID="DDLSample" OnSelectedIndexChanged="DDLSample_SelectedIndexChanged" runat="server"><br /> <asp:ListItem Text="Sample1" Value="0"></asp:ListItem><br /> <asp:ListItem Text="Sample2" Value="1"></asp:ListItem><br /> <asp:ListItem Text="Others..." Value="2"></asp:ListItem><br /> </asp:DropDownList> <br /></code><br /></pre><p>and a textbox</p><pre><br /><code><asp:TextBox ID="txtOthers" runat="server" Visible ="false" CssClass="form-control" ></asp:TextBox><br /></code><br /></pre><p>What I plan to do is that when "Others..." is selected from the drop down list, it will show the Others field.</p><p>on my aspx.cs, I have this code</p><pre><br /><code>protected void Page_Load(object sender, EventArgs e)<br /> {<br /> DDLSample.SelectedIndexChanged += new EventHandler(DDLSample_SelectedIndexChanged);<br /> DDLSample.AutoPostBack = true;<br /> }<br /><br /> void DDLSample_SelectedIndexChanged(object sender, EventArgs e)<br /> {<br /> if (DDLFindings.SelectedValue.ToString() == "2")<br /> txtOthers.Visible = true;<br /> else<br /> txtOthers.Visible = false;<br /> }<br /></code><br /></pre><p>but still, I keep getting this error</p><blockquote><p>CS1061: 'sample_aspx' does not contain a definition for 'DDLSample_SelectedIndexChanged' and no extension method 'DDLSample_SelectedIndexChanged' accepting a first argument of type 'sample_aspx' could be found (are you missing a using directive or an assembly reference?)</p></blockquote><br /><h2>Click here view more answers <a href="%20http://stackoverflow.com/questions/34470351/compiler-error-message-cs1061-aspx">http://ift.tt/1YHObtR</a></h2>
Nhận xét
Đăng nhận xét