The name 'grdUserActivity' does not exist in the current context - c#

I have a grid that is named grdUserActivity. I'm not sure what the error means.
The name 'grdUserActivity' does not exist in the current context
C#
public partial class frmViewPersonnel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
// Declares the DataSet
dsUserActivity myDataSet = new dsUserActivity();
// Fill the dataset with what is returned from the function
myDataSet = clsDataLayer.GetUserActivity(Server.MapPath("PayrollSystem_DB.mdb"));
// Sets the DataGrid to the DataSource based on the table
grdUserActivity.DataSource = myDataSet.Tables["tblUserActivity"];
// Binds the DataGrid
grdUserActivity.DataBind();
}
}
}
.ASPX
<%# Page Language="C#" AutoEventWireup="true" CodeFile="frmPersonnel.aspx.cs" Inherits="frmPersonnel" %>
<!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 runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div align="center">
</div>
<asp:Panel ID="Panel1" runat="server" Height="250px" HorizontalAlign="Left"
Width="300px">
<asp:Label ID="Label1" runat="server" Text="First Name:" Width="80px"></asp:Label>
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Last Name:" Width="80px"></asp:Label>
<asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label3" runat="server" Text="Pay Rate:" Width="80px"></asp:Label>
<asp:TextBox ID="txtPayRate" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label4" runat="server" Text="Start Date:" Width="80px"></asp:Label>
<asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label5" runat="server" Text="End Date:" Width="80px"></asp:Label>
<asp:TextBox ID="txtEndDate" runat="server"></asp:TextBox>
<br />
<asp:Button ID="btnSubmit" runat="server"
PostBackUrl="~/frmPersonnalVerified.aspx" Text="Submit"
onclick="btnSubmit_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
<br />
<asp:Label ID="lblError" runat="server"></asp:Label>
</asp:Panel>
</form>

Not sure if this is a type-o
But your aspx file is pointing to frmUserActivity rather than frmViewPersonnel
<%# Page Language="C#" AutoEventWireup="true" CodeFile="frmUserActivity.aspx.cs" Inherits="frmUserActivity" %>
So either you are editing the wrong .cs file, OR the wrong .aspx file ;)
EDIT
After seeing your edits, your frmUserAcitivty aspx page does not contain the grdUserActivity control. So of course it wont be found.

Related

Need to clear values of textboxes placed in update panel after button click

I have few textboxes in an update panel. On button click the values of textboxes is inserted into the database. I want the values to get cleared once the data has been inserted into the database.
PS: I tried to clear the values using a function after calling it once the data has been inserted. It doesn't work.
ASP
<%# Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="CalenderTest.aspx.cs" Inherits="DynamicCalender.CalenderTest" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 363px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1"runat="server"></asp:ToolkitScriptManager>
<div>
<div>
<asp:Label ID="lbl_year" runat="server" Text="Year"></asp:Label>
<asp:DropDownList ID="ddl_year" runat="server"></asp:DropDownList>
<asp:Label ID="lbl_train" runat="server" Text="Training"></asp:Label>
<asp:DropDownList ID="dd1_training" runat="server"></asp:DropDownList>
<asp:Button ID="btnsave" runat="server" Text="Create Batches" OnClick="btnsave_Click"/>
<br />
<br />
<asp:UpdatePanel ID="pnl1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="ss" runat="server" Text="session"></asp:Label>
<asp:Label runat="server" Text="Venue"></asp:Label>
<asp:TextBox ID="venue" runat="server" CausesValidation="false"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="Time"></asp:Label>
<asp:DropDownList ID="ddltime" runat="server" ></asp:DropDownList>
<asp:Label ID="Label2" runat="server" Text="Faculty"></asp:Label>
<asp:TextBox ID="faculty" runat="server" CausesValidation="false"></asp:TextBox>
<asp:Label ID="Label3" runat="server" Text="Module Details"></asp:Label>
<asp:TextBox TextMode="MultiLine" id="module_det" runat="server" CausesValidation="false"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="Add" OnClick="Button1_Click" />
<asp:Button id="Button2" runat="server" Text="Next" OnClick="Button2_Click"/>
<asp:TextBox ID="caldt" runat="server" CausesValidation="false"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="caldt"></asp:CalendarExtender>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
<asp:HiddenField ID="hd01" runat="server" />
<asp:HiddenField ID="hd02" runat="server" />
</div>
</div>
C#
protected void Button1_Click(object sender, EventArgs e)
{
sess_datetime = caldt.Text + " " + ddltime.SelectedItem.Value.ToString();
str1 = "Insert into sessDetail (tid,bid,sid,dt,faculty,venue,status) values(#tid,#bid,#sid,#dt,#faculty,#venue,#status)";
cmd = new SqlCommand(str1, con);
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("#tid", dd1_training.SelectedItem.Value);
cmd.Parameters.AddWithValue("#bid",Session["bid"]);
cmd.Parameters.AddWithValue("#sid",Session["sid"]);
cmd.Parameters.AddWithValue("#dt", sess_datetime);
cmd.Parameters.AddWithValue("#faculty", faculty.Text);
cmd.Parameters.AddWithValue("#venue", venue.Text);
cmd.Parameters.AddWithValue("#status", "0");
cmd.ExecuteNonQuery();
con.Close();
clear();
}
protected void clear
{
try
{
foreach (var pnl in pnl1.Controls)
{
var tb = pnl as TextBox;
if (tb != null)
{
tb.Text = "";
}
}
ddltime.ClearSelection();
}
catch(Exception x)
{
Response.Write(x.Message);
}
}
Wrap the Controls inside the UpdatePanel with a PlaceHolder and use that for the foreach loop.
<asp:UpdatePanel ID="pnl1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:PlaceHolder ID="PlaceHolder1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</asp:PlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
Code behind
foreach (var pnl in PlaceHolder1.Controls)
{
//clear controls
}

aspx page object behind a MasterPage object page object?

I have a drop down menu in my MasterPage file that drops down behind objects on the aspx page. I have used CSS to apply a z-index of 100 to the masterPage menu and a z-index of -1 to the tag in the aspx page. I have added position: relative; in the CSS for each. This is not working. It occurred to me that this might not even be possible to do? But surely others have a drop down menu in their masterPage file and it works correctly (doesn't get hidden by items in the page below). does anyone know if what I am trying to do is possible. and if so, does anyone have any ideas for what I might be doing incorrectly?
MasterPage code:
</head>
<body class="innermainbg">
<form id="Form1" runat="server">
<div>
<div class="header">
<div id="nav" class="clear hideSkiplink nav" >
<asp:Menu ID="NavigationMenu" runat="server" Orientation="Horizontal" CssClass="menu" >
<staticmenuitemstyle horizontalpadding="20"/>
<Items>
<asp:MenuItem Text="Search" NavigateUrl="~/Default.aspx" Value="Item1" >
<asp:MenuItem Text="Search By Age" NavigateUrl="~/SearchByAge.aspx" Value="Sub Item2"></asp:MenuItem>
<asp:MenuItem Text="Search By Price" NavigateUrl="~/SearchByPrice.aspx" Value="Sub Item3"></asp:MenuItem>
<asp:MenuItem Text="Search By Date" NavigateUrl="~/SearchByDate.aspx" Value="Sub Item2"></asp:MenuItem>
<asp:MenuItem Text="Search By Type" NavigateUrl="~/SearchByType.aspx" Value="Sub Item3"></asp:MenuItem>
<asp:MenuItem Text="Advanced Search" NavigateUrl="~/AdvSearch.aspx" Value="Sub Item1"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="Get Listed Free!" NavigateUrl="~/GetListed.aspx" Value="Item2">
</asp:MenuItem>
<asp:MenuItem Text="Advertise" NavigateUrl="~/Advertise.aspx" Value="Item2">
<asp:MenuItem Text="Links" NavigateUrl="~/Links.aspx" Value="Sub Item1"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="About" NavigateUrl="~/About.aspx" Value="Item2">
<asp:MenuItem Text="Terms" NavigateUrl="~/Terms.aspx" Value="Sub Item1"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="Contact" NavigateUrl="~/Contact.aspx" Value="Item2">
<asp:MenuItem Text="Help" NavigateUrl="~/Help.aspx" Value="Sub Item1"></asp:MenuItem>
<asp:MenuItem Text="FAQs" NavigateUrl="~/FAQs.aspx" Value="Sub Item2"></asp:MenuItem>
</asp:MenuItem>
</Items>
</asp:Menu>
</div>
</div>
<div class="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</div>
<div class="clear"></div>
</div>
<div></div>
<div class="footerholder">
<div id="footerContent" class="footer">
© 2014 Professional Expressions Inc. ClassesnWorkshops.com is a registered Trademark of Professional Expressions Inc. All rights reserved.
</div>
</div>
</form>
</body>
</html>
parial CSS code:
.back
{
position: relative;
z-index: -1;
}
div.menu
{
padding: 0px 0px 0px 0px;
float: right;
width: 100%;
position: relative;
z-index: 100;
}
ClassResults.aspx page code:
<%# Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"
CodeBehind="ClassResults.aspx.cs" Inherits="ClassesnWorkshops.ClassResults" %>
ZipCode:
Distance:
lblSearchWords
<div align="left" style="background-color: transparent; height: 250px; float:left; width:100%; background-repeat:no-repeat; background-position: 50% 50%;">
<div style="width:13%; float:left; display:inline;" class="rtPad10px">
<asp:Image ID="spacer1" runat="server" ImageUrl="~/Images/spacer_130x18px.png" />
</div>
<div style="width:69%; height:100%; float:left; display:inline;">
<br />
<asp:Label ID="lblTotalItemCount" runat="server" Enabled="False"></asp:Label>
<asp:Label ID="lblCurrentPage" runat="server" Enabled="False"></asp:Label>
<asp:Label ID="lblSort" runat="server" Enabled="False" >Sort:</asp:Label>
<asp:DropDownList ID="ddlSort" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlSort_SelectedIndexChanged" ViewStateMode="Enabled" EnableViewState="true" >
<asp:ListItem Value="Title">Class Title</asp:ListItem>
<asp:ListItem Value="schoolName">School Name</asp:ListItem>
<asp:ListItem Value="ClassSubject">Subject</asp:ListItem>
<asp:ListItem Value="Miles">Distance</asp:ListItem>
<asp:ListItem Value="lowestCost">Cost (low to high)</asp:ListItem>
<asp:ListItem Value="dateStart">Start Date</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnSort" runat="server" Text="Sort" onclick="btnSort_Click" />
<asp:Label ID="lblItemsPerPage" runat="server" Enabled="False">Items per page:</asp:Label>
<asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="True"
ViewStateMode="Enabled" EnableViewState="true" onselectedindexchanged="ddlPageSize_SelectedIndexChanged">
<asp:ListItem Text="1" Selected="True" Value="1"></asp:ListItem>
<asp:ListItem Text="10" Value="10"></asp:ListItem>
<asp:ListItem Text="20" Value="20"></asp:ListItem>
<asp:ListItem Text="50" Value="50"></asp:ListItem>
<asp:ListItem Text="100" Value="100"></asp:ListItem>
<asp:ListItem Text="200" Value="200"></asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:Label ID="lblValidationZip" runat="server" Enabled="False" ForeColor="Red" Text="A valid 5 digit zipCode is required."></asp:Label><br />
<asp:Label ID="lblMessage" runat="server" Text="lblMessage"></asp:Label>
<br />
<asp:Label ID="lblMsgTooManyOrTooFew" runat="server" Text=""></asp:Label>
<br />
<asp:Repeater ID="rptClasses" runat="server" >
<ItemTemplate>
<asp:Table runat="server" ID="tblClassesReturned" style="width:99%" >
<asp:TableRow ID="TableRow1" runat="server">
<asp:TableCell style="width:15%; text-align:left;">
<img src='C:\Users\Teresa\My Webs\ClassesnWorkshops\ClassesnWorkshops\images\logos\<%# DataBinder.Eval(Container.DataItem, "logoID") %>.jpg' align="left" alt="School Logo">
</asp:TableCell>
<asp:TableCell ID="TableCell1" runat="server" style="width:41%; float:left; text-align:left;">
Subject: <%# String.Format("{0:0.0}", DataBinder.Eval(Container.DataItem, "ClassSubject")) %><br />
<b>Title: <asp:HyperLink ID="hlClass" NavigateUrl='<%#"~/Class.aspx?classID=" + DataBinder.Eval(Container.DataItem, "ClassID")%>' Text=<%# String.Format("{0:0.0}", DataBinder.Eval(Container.DataItem, "ClassTitle")) %> Target="_blank" runat="server" /> </b><br></br>
<asp:Label ID="lblCostRange" ToolTip="Lowest price usually indicates residence, member or early bird cost. Highest price usually indicates non-residence, non-member or non-earlybird cost." runat="server">
Cost Range: <%# String.Format("{0:c}", DataBinder.Eval(Container.DataItem, "lowestCost")) %> - <%# String.Format("{0:c}", DataBinder.Eval(Container.DataItem, "highestCost")) %><br />
</asp:Label>
<asp:Label ID="lblCostNote" runat="server" font-size="8pt">
* Additional Fees or Discounts May Apply.
</asp:Label>
<br />
<asp:Label ID="lblClassSeason" ToolTip="Season that this class is held." runat="server">
<%# String.Format("{0:0.0}", DataBinder.Eval(Container.DataItem, "ClassSeason")) %>
</asp:Label>
<asp:Label ID="lblClassYear" ToolTip="Year that this class is held" runat="server">
<%# String.Format("{0:0}", DataBinder.Eval(Container.DataItem, "ClassYear")) %>
</asp:Label>
<asp:Label ID="ClassDays" ToolTip="Days of the Week this class is held: M=Monday, T=Tuesday, W=Wednesday, H=Thursday, F=Friday, A=Saturday, S=Sunday" runat="server">
<%# String.Format("{0:0.0}", DataBinder.Eval(Container.DataItem, "ClassDays")) %>
</asp:Label>
<%# String.Format("{0:0.0}", DataBinder.Eval(Container.DataItem, "ClassStartTime")) %><br />
</asp:TableCell><asp:TableCell ID="TableCell2" runat="server" style="width:44%; float:left; text-align:left;">
<b><asp:HyperLink ID="HyperLink1" NavigateUrl="~/School.aspx" Text=<%# DataBinder.Eval(Container.DataItem, "schoolName") %> Target="_blank" runat="server" /> </b>
-
<%# String.Format("{0:0.0}", DataBinder.Eval(Container.DataItem, "Miles")) %> miles away
<br />
Campus: <%# DataBinder.Eval(Container.DataItem, "campus") %><br />
<%# DataBinder.Eval(Container.DataItem, "street") %>
<%# DataBinder.Eval(Container.DataItem, "city") %>,
<%# DataBinder.Eval(Container.DataItem, "state") %>
<%# DataBinder.Eval(Container.DataItem, "zip") %><br />
<asp:HyperLink ID="hlSchool" NavigateUrl=<%# DataBinder.Eval(Container.DataItem, "web") %> Text=<%# DataBinder.Eval(Container.DataItem, "web") %> Target="_blank" runat="server" /> <br>
<%-- %><br><%# DataBinder.Eval(Container.DataItem, "longDesc") --%>
</asp:TableCell></asp:TableRow></asp:Table><br /><hr>
<br />
</ItemTemplate>
</asp:Repeater>
<br />
<asp:LinkButton ID="LnkFirst" runat="server" onclick="LnkFirst_Click">First</asp:LinkButton> <asp:LinkButton ID="LnkPrevious" runat="server" onclick="LnkPrevious_Click">Previous</asp:LinkButton> <asp:Repeater ID="rptPages" runat="server">
<ItemTemplate>
<asp:LinkButton ID="btnPage" CommandName="Page" CommandArgument="<%# Container.DataItem %>" runat="server">
<%# Container.DataItem %>
</asp:LinkButton> </ItemTemplate></asp:Repeater> <asp:LinkButton ID="LnkNext" runat="server" onclick="LnkNext_Click">Next</asp:LinkButton> <asp:LinkButton ID="LnkLast" runat="server" onclick="LnkLast_Click">Last</asp:LinkButton><br />
<br />
<%--
<asp:Label ID="lblValidationZip" runat="server" Enabled="False" ForeColor="Red" Text="A valid 5 digit zipCode is required."></asp:Label><br />
<asp:Label ID="lblMessage" runat="server" Text="lblMessage"></asp:Label>
<br />
<asp:Label ID="lblMsgTooManyOrTooFew" runat="server" Text=""></asp:Label>
--%>
</div><div style="width:17%; float:left; display:inline;" ><asp:Image
ID="spacer2" runat="server" ImageUrl="~/Images/spacer_170x18px.png" /></div></div></asp:Content>
Check your css and html structure using inspect element tool of browser. Open site in browser, right click on it, on bottom of menu you will inspect element option.
This will give you view of complete html and your css. you can edit the css and it will give you instant change on your page.

How to get web user control's text box value using javascript

I am developing an calendar user control using Ajax calendar extender.
User control code
<%# Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" ClientIDMode="Predictable" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxControl" %>
<link rel="stylesheet" href="GridViewCSSThemes/YahooGridView.css" type="text/css" media="screen" />
<div style="position:relative;border:none;">
<asp:TextBox ID="txtDate" MaxLength="10" ToolTip="DD/MM/YYYY" Width="100"
CssClass="tb10" runat="server">
</asp:TextBox>
<asp:ImageButton ImageUrl="~/GridViewCSSThemes/Images/Calendar_scheduleHS.png" ID="imgCalender" runat="Server"
BorderWidth="0" ImageAlign="absmiddle" />
<ajaxControl:CalendarExtender ID="AjaxCalenderCtrl" runat="server" Format="dd/MM/yyyy" PopupPosition ="TopLeft"
TargetControlID="txtDate" CssClass="red" FirstDayOfWeek="Sunday" PopupButtonID="imgCalender">
</ajaxControl:CalendarExtender>
<ajaxControl:TextBoxWatermarkExtender WatermarkCssClass="tb10" ID="txtWaterMarkDate"
runat="server" WatermarkText="DD/MM/YYYY" TargetControlID="txtDate">
</ajaxControl:TextBoxWatermarkExtender>
<ajaxToolkit:MaskedEditExtender ID="MaskedEdit_dt" runat="server"
TargetControlID="txtDate"
Mask="99/99/9999"
MessageValidatorTip="true"
OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
MaskType="Date"
AcceptAMPM="true"
AcceptNegative="Left"
ErrorTooltipEnabled="True" />
<ajaxToolkit:MaskedEditValidator ID="MaskedEditV_dt" runat="server"
ControlExtender="MaskedEdit_dt"
ControlToValidate="txtDate"
EmptyValueMessage="Date is required"
InvalidValueMessage="Date is invalid"
Display="Dynamic"
TooltipMessage="Input a date"
EmptyValueBlurredText="Date is required"
InvalidValueBlurredMessage="Date is invalid"
IsValidEmpty="false"
ValidationGroup="MKE" />
<%--<asp:RegularExpressionValidator ID="regexpvalEndDateEdit" ErrorMessage="!" ValidationExpression="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d"
ControlToValidate="txtDate" runat="server"></asp:RegularExpressionValidator>--%>
</div>
Code behind user control
internal string _DValue;
public string DValue
{
get
{
if (_DValue == "")
{
_DValue = txtDate.Text;
}
else
{
txtDate.Text = _DValue;
}
return _DValue;
}
set { _DValue = value; }
}
public string IdClientId
{
get { return this.ClientID; }
}
protected void Page_Load(object sender, EventArgs e)
{
}
I am able to get controls value using server side code.
Now i need to access text-box(txtDate) value and MaskedEditValidator(MaskedEditV_dt) inerHtml from javascript.
How can i do this.
Edit-1
User control in aspx page
<%# Page Language="C#" AutoEventWireup="true" CodeFile="CustomControlTest2.aspx.cs" Inherits="CustomControlTest2" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxControl" %>
<%# Register TagPrefix="uc1" TagName="UCCalender" Src="~/WebUserControl.ascx" %>
<!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 runat="server">
<title>User Control Test</title>
</head>
<body>
<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager runat="server" ID="ScriptManager1" EnablePageMethods="true" />
<div>
<table>
<tr>
<td>
<uc1:UCCalender ID="UCCalStartDate" runat="server" DValue="" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnExe" runat="server" Text="Submit" onclick="btnExe_Click" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblMsg" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
Code behind
protected void btnExe_Click(object sender, EventArgs e)
{
lblMsg.Text = UCCalStartDate.DValue;
}
ASP.NET loads to display the UserControl, it ONLY renders the contents of the UserControl. The Controls in the usercontrol will rendered with the ID as $content_UControlName_Control. You can check this after the rendering the page. You can access the contol using that ID from Javascript like document.getElementById(content_UControlName_Control).
Finally i got answer. Thanks to Nag
On button click
<asp:Button ID="btnExe" runat="server" Text="Submit" OnClientClick="getValue('UCCalStartDate_txtDate','UCCalStartDate_MaskedEditV_dt');" onclick="btnExe_Click" />
Javascript
function getValue(id,msk) {
alert(document.getElementById(id).value);
alert(document.getElementById(msk).innerHTML);
}
Finaly i am able to access calander control's text-box value using java-script

label.visible = true not working

The visible function doesnt work, but why? Is a true set in a callback not allowed?. When I set the visible to true on top of the page(_Default : System.Web.UI.Page) it is working.
information_remedyID.Visible = true;
information_remedyID.Text = inquiryId;
TOP Class:
public partial class _Default : System.Web.UI.Page
{
.......
private static string inquiryId;
......
private void InsertIncidentCallback(server3.ILTISAPI api, IAsyncResult result, string username, string msg_id)
{
string message;
api.EndInsertIncident(result, out message);
if (message == null)
{
string responseXML;
api.REMEDY_ReadResponseXML(username, out responseXML, out msg_id);
XDocument doc = XDocument.Parse(responseXML);
inquiryId = (string)doc.Root.Element("inquiry_id");
if (inquiryId == null | inquiryId == "")
{
information_text.Text = "....";
}
else
{
information_remedyID.Visible = true;
information_remedyID.Text = inquiryId;
//create_LanDesk(computer_idn, swidn_choice, swName_choice, inquiryId);
}
}
else
{
information_text.Visible = true;
information_text.Text = "...";
}
}
}
asp:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>Willkommen im BISS</title>
</head>
<body>
<form id="form1" runat="server">
<span style="font-size: 16pt"><strong>BISS<br />
</strong><span style="font-size: 12pt">
<br />
Angemeldet als:
<asp:Label ID="user_id" runat="server" Text="user_id"></asp:Label><br />
Hostname:
<asp:Label ID="hostname_id" runat="server" Text="hostname_id"></asp:Label>
<br />
CI Nummer:
<asp:Label ID="CI_NR" runat="server" Text="CI_NR"></asp:Label></span></span>
<br />
<br />
<asp:DropDownList ID="softwarelist" runat="server" DataTextField="SoftwareName" DataValueField="SoftwareName">
<asp:ListItem Text="Bitte Software auswählen" Value=""></asp:ListItem>
</asp:DropDownList>
<asp:Button ID="requestbt" runat="server" OnClick="Button1_Click" Text="Software zuweisen" /><br />
<asp:Label ID="information_text" runat="server" Text="information_text" Visible="False"></asp:Label><br />
<asp:Label ID="information_remedyID" runat="server" Text="information_remedyID" Visible="False"></asp:Label>
<br />
</form>
</body>
</html>
Do you use a UpdatePanel with UpdateMode="Conditional"
<asp:UpdatePanel ID="ProfileEditingUpdatePanel" runat="server" UpdateMode="Conditional">
In case you use WPF
information_remedyID.Visibility = Visibility.Visible;
Sorry, overread ASP!
if (inquiryId == null | inquiryId == "")
If this should be an or change it to a double stripe:
if (inquiryId == null || inquiryId == "")
Use a UpdatePanel, like this:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>Willkommen</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="MyUpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<span style="font-size: 16pt">
<strong>
BISS<br />
</strong>
<span style="font-size: 12pt">
<br />
Angemeldet als:
<asp:Label ID="user_id" runat="server" Text="user_id"></asp:Label><br />
Hostname:
<asp:Label ID="hostname_id" runat="server" Text="hostname_id"></asp:Label>
<br />
CI Nummer:
<asp:Label ID="CI_NR" runat="server" Text="CI_NR"></asp:Label></span></span>
<br />
<br />
<asp:DropDownList ID="softwarelist" runat="server" DataTextField="SoftwareName" DataValueField="SoftwareName">
<asp:ListItem Text="Bitte Software auswählen" Value=""></asp:ListItem>
</asp:DropDownList>
<asp:Button ID="requestbt" runat="server" OnClick="Button1_Click" Text="Software zuweisen" /><br />
<asp:Label ID="information_text" runat="server" Text="information_text" Visible="False"></asp:Label><br />
<asp:Label ID="information_remedyID" runat="server" Text="information_remedyID" Visible="False"></asp:Label>
<br />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
And in your code, after you changed the visibility:
MyUpdatePanel.Update();
I couldn't get this to work either.
A workaround is to use Style="display: none;" instead of Visible="False". Then you can reveal it with
information_remedyID.Style["display"] = "initial";

Problem with ajax tabcontainer

i use from ajax tabcontainer .and i want to when value of hiddenfield is not 1(value of hiddenfield change when i click in gridview,i dont have problem with set value for hiddenfield) and user click in email tab it alerts and stays in first tab.but in my code it alert and changes tab.i want to stay in cuurent tab.
i write this code but it dosent work.
please help me.
<%# Page Language="C#" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org
<script type="text/javascript">
function SetActiveTab() {
var hfd = $get('<%=HiddenField1.ClientID%>');
if (hfd.value != "1") {
alert("hitttttttt");
var ctrl = $find('TabContainer1');
ctrl.set_activeTab(ctrl.get_tabs()[0]);
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Ajax Control - Tabs </title>
</head>
<body>
<form id="form1" runat="server">
<b>Tabs Demonstration</b> <br />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:HiddenField ID="HiddenField1" runat="server" />
<br />
<asp:TabContainer runat="server" ID="TabContainer1" Height="138px" ActiveTabIndex="0"
Width="402px">
<asp:TabPanel runat="server" ID="Panel1" HeaderText="Address" >
<ContentTemplate>
<asp:UpdatePanel ID="updatePanel1" runat="server">
<ContentTemplate>
<table>
<tr><td>First Name:</td><td><asp:TextBox ID="txtName" runat="server" /></td></tr>
<tr><td>Address:</td><td><asp:TextBox ID="txtAddress" runat="server" /></td></tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel runat="server" ID="Panel3" HeaderText="Email" OnClientClick="SetActiveTab" >
<ContentTemplate>
Email: <asp:TextBox ID="txtEmail" runat="server" />
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel runat="server" ID="Panel2" HeaderText="Login Details" >
<ContentTemplate>
<table>
<tr> <td>User Name:</td><td><asp:TextBox ID="txtUser" runat="server" /></td></tr>
<tr> <td>Password:</td><td><asp:TextBox ID="txtPass" runat="server" /></td></tr>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
</form>
The one solution I found is to remove OnClientClick handler and use the javascript below:
function pageLoad() {
var tabContainer = $find('<%= TabContainer1.ClientID %>');
var hfd = $get('<%= HiddenField1.ClientID %>');
var oldSetActiveTab = Function.createDelegate(tabContainer, tabContainer.set_activeTab);
tabContainer.set_activeTab = function (value) {
if (value.get_id() == '<%= Panel3.ClientID %>' && hfd.value != "-1") {
alert("oops");
}
else {
oldSetActiveTab(value);
}
};
}

Categories