TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kriti
NA
60
0
retreiving the value of hidden field from .ascx file to ascx.cs file
Dec 30 2009 9:58 AM
My code in program.ascx is
<form id="form1" runat="server">
<ItemTemplate>
<div>
<input id="inpHide" type="hidden" runat="server" />
<asp:DropDownList id="dd" runat="server" onselectedindexchanged="dd_SelectedIndexChanged" onChange="ConfirmIt()" AutoPostBack="true" >
<asp:ListItem Value="Pending">Pending</asp:ListItem>
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No">No</asp:ListItem>
</asp:DropDownList>
</div>
</ItemTemplate>
</asp:TemplateColumn>
</form>
My javascript function is
<head runat="server">
<SCRIPT language="javascript">
function ConfirmIt() {
var x = confirm("Do you Want to notify changes to User ??");
var control = '<%=inpHide.ClientID%>';
if (x == true) {
document.getElementById(control).value = "1";
}
else {
document.getElementById(control).value = "0";
}
}
</SCRIPT>
</head>
My code in the Program.ascx.cs
protected void dd_SelectedIndexChanged(object sender, EventArgs e)
{
int DiagResult = int.Parse(inpHide.Value);
if (DiagResult == 1)
{
//Do Somthing
Response.Write("You Have Selected Ok");
}
else if (DiagResult == 0)
{
//Do somthing
Response.Write("You have Selected Cancel");
}
}
In short whenever the dropdown list value changes,It should notify change to user.
I got the same code from this forum but they did it in page i.e. aspx and aspx.cs.,Dat is working fine ...But when i am implementing in usercontrol like above (and integrating the code in my project) ..Its giving error as impHide is unknown in the following context.means the value is not retrieved from the Program.ascx file.I am unable to find the main cause.
Pls help me to solve this
Thanks...
Reply
Answers (
2
)
Form in C#
Validating and processing asp.net textbox