Forums » .NET » ASP.NET »

Add Text in Drop Down List


Posted Date: 31 Oct 2008      Posted By:: Asad Moosa     Member Level: Silver    Member Rank: 0     Points: 1   Responses: 3



When we have drop down list to select "add text", it should change to text box to enter. Is it possible? ASP Net 2.0 using C#?

Please let me know.

Thank you.





Responses

#312267    Author: Jai      Member Level: Gold      Member Rank: 137     Date: 01/Nov/2008   Rating: 3 out of 53 out of 53 out of 5     Points: 3

u should have a textbox and a drop down..
at the page load the visibility of the textbox should be hidden

on the onchange event of drop down u should call this javascript function

Eg;

<asp:DropDownList id="ddlOutCome" runat="server" onchange="Show_TextBox()"></asp:DropDownList>

<asp:TextBox style="DISPLAY: none" id="txtIOutCome" runat="server" MaxLength="140"></asp:TextBox>

function Show_TextBox()
{
if(document.getElementById('ddlOutCome').value=="Add Text")
{
document.getElementById('txtOutCome').style.display='block';
}
else if(document.getElementById('ddlOutCome').value!="Add Text")
{
document.getElementById('txtOutCome').style.display='none';
}
}


 
#312268    Author: Raji      Member Level: Gold      Member Rank: 1729     Date: 01/Nov/2008   Rating: 1 out of 5     Points: 1

hi

try to set visibility of the textbox on dropdownlist selected index changed event

<table cellpadding="0" cellspacing="0" border="0" width="100%" >
<tr>
<td >Choose TExt:</td>
<td align="left" valign="middle"><asp:DropDownList ID="ddlPackage" runat="server" DataTextField="Category" DataValueField="ID">
<asp:ListItem value="0"> -- Add Text--</asp:ListItem>
</asp:DropDownList> <asp:TextBox ID="txtCategory" runat="server" MaxLength="40" Visible="False"></asp:TextBox>
<asp:Button ID="btnSave" runat="server" Text="SAVE" CssClass="butcolor" OnClick="btnSave_Click"/>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="butcolor" OnClick="btnCancel_Click"/></td>
</tr>
</table>


Page_Load()
{
if(!IsPostback())
{
txtCategory.visible=false;
btnSave.visible=false;
btnCancel.visible=false;
}

}

on ddlPackage_SelectedIndexChanged()
{
if(ddlPackage.SelectedValue.Trim()=="0")
{
ddlPackage.visible=false;
txtCategory.visible=true;
btnSave.visible=true;
btnCancel.visible=true;
}
}

I think this'll help u

Regards
Raji


 
#312283    Author: Varun Bansal      Member Level: Gold      Member Rank: 423     Date: 01/Nov/2008   Rating: 2 out of 52 out of 5     Points: 2

try this
on page_load()
{
textbox1.visible=false;
btnsave.visible=false;
btncancel.visible=false;

}

ddl_SlectedindexChanged()

{

if(ddl.selecteditem.text="add text")
{
textbox1.visible=true;
btnsave.visible=true;
btncancel.visible=true;
}

Regards
Varun bansal
Do not forget to Rate the post.....





 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Return to Discussion Forum
Start new thread

Subscribe to Subscribers
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India