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

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

Related

Error rendering control. The server block is not well formed

This is user control page
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="UserInfoBoxControl.ascx.cs"
Inherits="WebApplication3.UserInfoBoxControl" %>
<b>Information about <%# this.UserName %></b><br /><br />
<%# this.UserName %> is <%# this.UserAge %> years old and lives in <%# this.UserCountry %>
Controller CS file
public partial class UserInfoBoxControl : System.Web.UI.UserControl
{
private string userName;
private int userAge;
private string userCountry;
public string UserName
{
get { return userName; }
set { userName = value; }
}
public int UserAge
{
get { return userAge; }
set { userAge = value; }
}
public string UserCountry
{
get { return userCountry; }
set { userCountry = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
webform on which i want to implement this.
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication3.WebForm1" %>
<%# Register TagPrefix="My" TagName="UserInfoBoxControl" src="~/UserInfoBoxControl.ascx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br /><br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<br /><br />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>No one</asp:ListItem>
<asp:ListItem>World</asp:ListItem>
<asp:ListItem>Universe</asp:ListItem>
</asp:DropDownList>
<br /><br />
<My:UserInfoBoxControl runat="server" ID="MyUserInfoBoxControl" />
</div>
</form>
</body>
</html>
Getting error
Error rendering control: Myuserinfoboxcontrol
the server block is now well formed.
i am not getting how to rectify it
i want to implement user control on my webform but i am getting this error. Need help. thanks
i guess this:
<b>Information about <%# this.UserName %></b><br /><br />
<%# this.UserName %> is <%# this.UserAge %> years old and lives in <%#
this.UserCountry %>
should be:
<b>Information about <%= this.UserName %></b><br /><br />
<%= this.UserName %> is <%= this.UserAge %> years old and lives in <%=
this.UserCountry %>

Click Event For Cross Page PostBack

I have a Search.aspx page with TextBox and Button. The postback is to Results.aspx which has a GridView. The Sql query works as I have checked it with QueryDesigner.
In theory, a pseudo-search should be done by typing a value into the text box and clicking the button. When I enter a value and click, the Results.aspx page opens but is blank.
The click event in the Search.aspx is nothing more than:
protected void Button2_Click(object sender, EventArgs e){}
This setup does work in a Web Project, however, will not in a Web Site, which this is. It would appear that the click event is not working by not submitting the value to the Results.aspx page. I have had no luck finding a click event which will work. I would appreciate any help.
EDIT: The sql query is complicated but as I said, it works fine when a value is entered in the Query Designer. I did add a "namespace" to the .cs as Web Sites, as opposed to Web Projects, normally do not have a namespace.
Search.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Search.aspx.cs" Inherits="LinqTest.Search" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!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>
<asp:TextBox runat="server" ID="Name"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Search" PostBackUrl="~/Results.aspx" />
</div>
</form>
</body>
</html>
Search.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace LinqTest
{
public partial class Search : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
}
}
}
ResultsSearch.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeFile="ResultsSearch.aspx.cs" Inherits="RecipeFaire.ResultsSearch" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%# PreviousPageType VirtualPath="~/Search.aspx" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<!-- this is the results of the search done on the search.aspx -->
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:ListView ID="ListView1" runat="server" DataKeyNames="RecipeID" DataSourceID="SqlDataSource1">
<ItemTemplate>
<tr>
<td rowspan="2">
<asp:Image ID="Image1" runat="server" Width="100px" Height="80px" ImageUrl='<%# "~/Handler.ashx?RecipeID=" + Eval("RecipeID")%>' />
</td>
<td rowspan="2" width="100px">
<asp:Rating ID="Rating1" runat="server" align="right" valign="top" CurrentRating='<%# Eval("RatingAVG")%>'
MaxRating="5" ReadOnly="true" StarCssClass="ratingStar" WaitingStarCssClass="savedRatingStar"
FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar">
</asp:Rating>
&nbsp&nbsp&nbsp<br></br>
<asp:Label ID="Label7" runat="server" align="right" Text='<%# Eval("Count") %>' />&nbsp&nbsp
<asp:HyperLink ID="Home" Font-Size="Small" runat="server" NavigateUrl='<%# Bind("RecipeID", "../../Comments.aspx?RecipeId={0}") %>'
Text="Reviews" />
</td>
<td>
<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# Bind("RecipeID", "PageLinkDetails.aspx?RecipeId={0}") %>'
Text='<%# Eval("RecipeName") %>'></asp:HyperLink>
</td>
</tr>
<tr style="width: 500px">
<td>
<asp:Label ID="DescriptionLabel" valign="top" runat="server" Text='<%# Eval("Description") %>' />
</td>
</tr>
<tr>
<td colspan="5" style="color: LightGrey">
<asp:Label ID="Label2" runat="server" Font-Size="1px" Height="1px" Text='<%# Eval("RecipeID") %>'></asp:Label>
<hr style="border-style: dotted" />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<asp:LinkButton
runat="server" ID="SortByName" CommandName="Sort" CommandArgument="RecipeName">Sort By Recipe Name</asp:LinkButton>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
<asp:LinkButton runat="server" ID="SortByPrice" CommandName="Sort" CommandArgument="RatingAVG">Sort By Rating</asp:LinkButton>
<table id="Table1" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table id="itemPlaceholderContainer" runat="server" border="0" style="">
<tr id="Tr2" runat="server" style="">
<th id="Th1" runat="server">
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr3" runat="server">
<td id="Td2" runat="server" style="" align="center">
<asp:DataPager ID="DataPager2" PagedControlID="ListView1" PageSize="8" runat="server">
<Fields>
<asp:NumericPagerField ButtonCount="8" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:RecipeUploadConnectionString %>"
SelectCommand="SELECT pr.RecipeID, pr.CategoryName, pr.CategoryType, pr.RecipeName, pr.Description, COUNT(rr.RecipeID) AS Count, AVG(rr.Rating) AS RatingAVG
FROM PostedRecipes AS pr LEFT OUTER JOIN RecipeRatings AS rr ON pr.RecipeID = rr.RecipeID
WHERE pr.RecipeName LIKE '%' + #RecipeName + '%' OR pr.CategoryName LIKE '%' + #CategoryName + '%'
OR pr.CategoryType LIKE '%' + #CategoryType + '%' OR pr.CuisineOrigin LIKE '%' + #CuisineOrigin + '%'
OR pr.CuisineType LIKE '%' + #CuisineType + '%' GROUP BY pr.RecipeID, pr.RecipeName, pr.CategoryName, pr.CategoryType, pr.CuisineOrigin, pr.CuisineType, pr.Description">
<SelectParameters>
<asp:FormParameter FormField="RecipeName" Name="RecipeName" Type="String"/>
<asp:FormParameter FormField="CategoryName" Name="CategoryName" Type="String" />
<asp:FormParameter FormField="CategoryType" Name="CategoryType" Type="String"/>
<asp:FormParameter FormField="CuisineOrigin" Name="CuisineOrigin" Type="String" />
<asp:FormParameter FormField="CuisineType" Name="CuisineType" Type="String"/>
</SelectParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
ResultsSearch.cs
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using System.Web.SessionState;
namespace RecipeFaire
{
public partial class ResultsSearch : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
i am seeing something weird...
in your search.aspx... you have this.
<asp:Button ID="Button1" runat="server" Text="Search" PostBackUrl="~/Results.aspx" />
However, in your 2nd page listing... you posted this...
<%# Page Language="C#" AutoEventWireup="true" CodeFile="ResultsSearch.aspx.cs" Inherits="RecipeFaire.ResultsSearch" %>
the PostbackUrl is Results.aspx and the other page you posted in ResultsSearch.aspx.
Can you check if this is the problem? (i cant post comments yet.)
You definitely aren't showing us all of your code-behind, but we'll assume you are doing this somewhere:
ListView1.DataSource = SqlDataSource1;
ListView1.DataBind();
After you've done that, THEN you can find the Label and set its text (do not do this in the Page_Load prior to binding).
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
Label recipeName = (Label)e.Item.FindControl("labRecipeName");
recipeName.Text = Request.QueryString["RecipeName"].ToString()
}
}
To use a querystring value for your SqlDataSource, use a QueryStringParameter:
<SelectParameters>
<asp:QueryStringParameter Name="RecipeName" QueryStringField="RecipeName" Type="String" />
</SelectParameters>

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);
}
};
}

asynccontrols asp.net Error Creating Control " Object reference not set to an instance of an object"

here is my sample form.
I'm using asynccontrols
. Site compiles fine, loads fine, works fine. Can't view anything in designer. Halp?
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Calendar2.aspx.cs" Inherits="txssaAuction.Calendar2" %>
<%# Register Assembly="AsyncControls" Namespace="DelvingWare.AsyncControls" TagPrefix="dw" %>
<!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>
<dw:asynccalendar runat="server" ID="calMain"
DefaultStyle="false"
AbbreviateDays="true"
PreviousMonthText="<div class='navPrev' title='Previous Month'><<<</div>"
NextMonthText="<div class='navNext' title='Next Month'>>>></div>"
SelectedDayCssClass="selDay"
CssClass="asyncCalReg"
WeekendDayCssClass="weekend"
OtherMonthCssClass="otherMonth"
DayCssClass="calday"
Width="500"
MonthListCssClass="monthList"
YearListCssClass="yearList"
TodayCssClass="today"
TodayFooterCssClass="todayFooter"
DaySelectionMode="Multiple"
OnDaySelected="calMain_DaySelected"
MonthSelectorCssClass="monthSelector"
YearSelectorCssClass="yearSelector" />
<p>
<dw:asynclistbox runat="server" ID="lstMain"
SelectionMode="Single"
OnSelectedIndexChanged="lstMain_IndexChanged"
Rows="7">
<AsyncListItem Text="No Selected Dates" Value="none" />
</dw:asynclistbox>
<br/>
<dw:asynclinkbutton runat="server" ID="lnkMain"
ConfirmMessage="Are you sure you want to clear all selected dates?"
OnClick="lnkMain_Click">Clear Selected Dates</dw:asynclinkbutton>
</p>
</p>
<dw:AsyncRepeater ID="rptUsers" runat="server"
OnItemDataBound="rptUser_ItemDataBound"
EnableEffects="true"
RollACssClass="rollA"
RollBCssClass="rollB"
HighlightCssClass="highlight"
CssClass="asyncRep"
Visible="true">
<HeaderTemplate>
<table cellpadding="4">
<tr class="headlnk">
<td>
First Name
</td>
<td>
Last Name
</td>
<td>
Account Balance
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr $roll$ $highlight$>
<td>
<dw:AsyncLiteral runat="server" ID="ltlFirstName" />
</td>
<td>
<dw:AsyncLiteral runat="server" ID="ltlLastName" />
</td>
<td>
<dw:AsyncLiteral runat="server" ID="ltlAccBalance" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</dw:AsyncRepeater>
<br />
<dw:AsyncButton runat="server" ID="btMain"
OnClick="btMain_Click"
CssClass="greyButton">Re-Bind the AsyncRepeater</dw:AsyncButton>
</div>
</form>
</body>
</html>

Categories