call javascript from c# - c#

I know this question is asked before, and I looked it up, and found this sulotion:
Page.ClientScript.RegisterStartupScript(this.GetType(), "click", "test();", true);
so I put that in my c# method, and the following javascript code in my head.
<script type ="text/javascript">
function test() {
alert("succes");
}
</script>
this is my html where i call the code behind method.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="ampwirecalc">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="Inline">
<ContentTemplate>
<asp:DropDownList ID="dropdownsize" OnSelectedIndexChanged="wirecalc" onchange="runscalc()" AutoPostBack="true" runat="server">
<asp:ListItem Text="Select Wire Size" value="-1"/>
<asp:ListItem Text="1/0 gauge" Value="0" />
<asp:ListItem Text="4 gauge" Value="1" />
<asp:ListItem Text="8 gauge" Value="2" />
</asp:DropDownList>
<script type="text/javascript">
function runscalc()
{
var totalRMS = document.getElementById('<%=tbx_anw3.ClientID%>').value;
document.getElementById('<%=HiddenField1.ClientID%>').value = totalRMS;
}
</script>
<!--These are the texts giving information on the options-->
<div class="textwirecalc">
<p class="selectedwire">Selected Wire:</p>
<p class="neededruns">Needed Runs:</p>
<p class="selectedsize">Selected size:</p>
</div>
<!--These are the labels that wil show the calculated info-->
<div class="labelwirecalc">
<asp:Label ID="wiretype" runat="server" Text="Wire type will show here"></asp:Label>
<asp:Label ID="wireruns" runat="server" Text="Needed runs will show here"></asp:Label>
<asp:Label ID="wiresize" runat="server" Text="Wire size will show here"></asp:Label>
</div>
</ContentTemplate>
</asp:UpdatePanel>
does anyone know what I'm doing wrong, and what I should do instead.
thanks in advance.

Try this
Page.ClientScript.RegisterStartupScript(this.GetType(), "click", "test();", false);
Reference
last parameter true/false indicate- whether to add script tags.

you can give the javascript like below, no need to write javascript function
Page.ClientScript.RegisterStartupScript(this.GetType(), "click","alert('succes');", true);
UPDATE
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(),
"click", "alert('succes');", true);

The third parameter must be enclosed with script tags as the
http://msdn.microsoft.com/en-us/library/asz8zsxy.aspx says.

<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication2.WebForm1" %>
<!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>
<script type="text/javascript">
function test() {
alert("succes");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div id="ampwirecalc">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="Inline">
<ContentTemplate>
<asp:DropDownList ID="dropdownsize" onchange="runscalc()" AutoPostBack="true" runat="server" OnSelectedIndexChanged="dropdownsize_SelectedIndexChanged">
<asp:ListItem Text="Select Wire Size" Value="-1" />
<asp:ListItem Text="1/0 gauge" Value="0" />
<asp:ListItem Text="4 gauge" Value="1" />
<asp:ListItem Text="8 gauge" Value="2" />
</asp:DropDownList>
<script type="text/javascript">
</script>
<!--These are the texts giving information on the options-->
<div class="textwirecalc">
<p class="selectedwire">
Selected Wire:</p>
<p class="neededruns">
Needed Runs:</p>
<p class="selectedsize">
Selected size:</p>
</div>
<!--These are the labels that wil show the calculated info-->
<div class="labelwirecalc">
<asp:Label ID="wiretype" runat="server" Text="Wire type will show here"></asp:Label>
<asp:Label ID="wireruns" runat="server" Text="Needed runs will show here"></asp:Label>
<asp:Label ID="wiresize" runat="server" Text="Wire size will show here"></asp:Label>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
And code behind,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Page.ClientScript.RegisterStartupScript(this.GetType(), "click", "test();", true);
}
protected void dropdownsize_SelectedIndexChanged(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(),
"click", "test();", true);
}
}
}
Try this code.

Related

call script or function in update panel after every refresh click inside it

my header portion is
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>SimpleAdmin</title>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(function () {
$(".box .h_title").not(this).next("ul").hide("normal");
$(".box .h_title").not(this).next("#home").show("normal");
$(".box").children(".h_title").click(function () {$(this).next("ul").slideToggle(); });
});
</script>
</head>
And my body portion
<body>
<form id="form" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DataList ID="dtlheader" runat="server" Width="189px">
<ItemTemplate>
<table cellpadding="0" cellspacing="0" width="100%" onmouseover="this.style.background='#683372'" onmouseout="this.style.background='#3e3d3b'" style="background-color: #3e3d3b;">
<tr>
<td>
<div class="box">
<div class="h_title" style="color: #FFFFFF"><%# Eval("header") %></div>
<ul>
<asp:DataList ID="dtlsubtitle" runat="server">
<ItemTemplate>
<table cellpadding="0" cellspacing="0" width="100%" onmouseover="this.style.background='#ececec'"
onmouseout="this.style.background='#ececec'" style="background-color: #ececec;"><tr><td>
<asp:LinkButton ID="lnk" runat="server" onclick="lnk_Click"><%# Eval("subtitle") %></asp:LinkButton>
</td></tr></table>
</ItemTemplate>
</asp:DataList>
</ul>
</div>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
this is a script of switchmenu
On page 1st load it is working good but on doing linkbutton clicking which is inside,
than after script does not get work again.
If I understood your problem, this should solve it:
Javascript
$(function () {
$(".box .h_title").not(this).next("ul").hide("normal");
$(".box .h_title").not(this).next("#home").show("normal");
});
function lbClicked(obj) {
$(obj).next("ul").slideToggle();
}
ASP.NET
<asp:LinkButton ID="lnk" runat="server" onclick="lnk_Click" onclientclick="lbClicked(this)"><%# Eval("subtitle") %></asp:LinkButton>
C#
protected void Page_Load(object sender, EventArgs e)
{
// You don't need the line below, which is wrong anyway
//ScriptManager.RegisterStartupScript(this, this.GetType(), "javascript", "function();", true);
}
protected void lnk_Click(object sender, EventArgs e)
{
// You don't need the line below, which is wrong anyway
//ScriptManager.RegisterStartupScript(this, this.GetType(), "javascript", "function();", true);
}

Page_Load executing Twice

I know that this question has been asked before, but none of the remedies seem to be my solution.
I have an aspx page and a code behind with a Page_Load routine. My routine writes a record to a SQL table to capture the user's credentials.
The Page_Load has a !IsPostBack check, aspx has AutoEventWireup="True", and I have no img or any other element that would cause an AutoPostback to my knowledge. Still Page_Load is called twice.
Here is my .aspx page and the code behind. I am hoping someone can help.
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="feedback.aspx.cs" Inherits="MEAU.Web.Components.SupportCenter.feedback" %>
<%# Import Namespace="Sitecore.Configuration" %>
<%# Import Namespace="Sitecore.Security.Accounts" %>
<%# Import Namespace="System.Data" %>
<%# Import Namespace="System.Data.SqlClient" %>
<!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">
<script type="text/javascript" src="/components/SupportCenter/design/js/jquery-1.8.1.min.js"></script>
<script type="text/javascript" src="/components/SupportCenter/design/js/jquery.easing.js"></script>
<script type="text/javascript" src="/components/SupportCenter/design/js/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript" src="/components/SupportCenter/design/js/jquery.accordion.js"></script>
<script type="text/javascript" src="/components/SupportCenter/design/js/jquery.pngFix.js"></script>
<script type="text/javascript" src="/components/SupportCenter/design/js/global.js"></script>
<script type="text/javascript" src="/components/SupportCenter/design/js/jquery-tmpl.js"></script>
<head id="Head1" runat="server">
<style>
p.titlefont
{
font-family: "Arial" , Helvetica, Sans-Serif;
font-size:"12px";
}
</style>
<title>Feedback</title>
<script type="text/javascript">
function Init() {
var obj = window.dialogArguments;
var url = document.getElementById("url1");
var login = document.getElementById("login");
}
function getRadioValue(theRadioGroup) {
for (var i = 0; i < document.getElementsByName(theRadioGroup).length; i++) {
if (document.getElementsByName(theRadioGroup)[i].checked) {
return document.getElementsByName(theRadioGroup)[i].id;
}
}
}
function WriteToFile(sText) {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fo = fso.OpenTextFile('c:\\\inetput\\wwwwroot\LogFile.txt', 8, true, 0); // 8=append, true=create if not exist, 0 = ASCII
fo.WriteLine();
fo.Write(sText);
fo.Close();
}
</script>
</head>
<!--<body onload="javascript:Init();"> -->
<body>
<form id="form1" runat="server">
<div>
<p class="titlefont">
<asp:Literal ID="quest" Text="Did this resolve your issue?" runat="server" />
<br />
<br />
<asp:CheckBox ID="yes" runat="server" Text="Yes" Checked="true"
Font-Names="Arial" Font-Size="12px" /><br />
<asp:CheckBox ID="no" runat="server" Text="No" Font-Names="Arial"
Font-Size="12px" /><br />
<asp:Literal ID="lit" Text="Please select at least one answer" runat="server" Visible="false"/><br />
<asp:CheckBox ID="scall" runat="server" Text="Did this prevent a Service Call?" Visible="false" Font-Names="Arial"
Font-Size="12px" /><br />
<asp:CheckBox ID="parts" runat="server" Text="Did this prevent a Parts Shipment?" Visible="false"
Font-Names="Arial" Font-Size="12px" /><br />
<asp:CheckBox ID="wrnt" runat="server" Text="Is this under Warranty?" Font-Names="Arial" Visible="false"
Font-Size="12px" /><br />
<asp:CheckBox ID="none" runat="server" Text="None of the above" Font-Names="Arial" Visible="false"
Font-Size="12px" /><br />
<br />
<asp:Button ID="run" Text="SUBMIT" OnClick="Run_Write" runat="server" Font-Names="Arial"
Font-Size="12px" /><br />
<asp:Button ID="cancel" Text=" CANCEL " OnClick="Cancel_btn" runat="server" Font-Names="Arial"
Font-Size="12px" />
</p>
</div>
</form>
</body>
</html>
my code Behind:
protected void Page_Load(object sender, EventArgs e)
{
login = Sitecore.Security.Accounts.User.Current.Profile.Email;
myurl = Request.QueryString["value"];
if (!IsPostBack)
{
// Write a record and capture the User's credententials, even if they do not take an action
SqlConnection conn = new SqlConnection(Sitecore.Configuration.Settings.GetConnectionString("feedback"));
SqlCommand cmd = new SqlCommand("Insert_fb", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("#login", login);
cmd.Parameters.AddWithValue("#url", myurl);
cmd.Parameters.AddWithValue("#response", "No");
cmd.Parameters.AddWithValue("#noResponse", "Yes");
cmd.Parameters.AddWithValue("#date", DateTime.Now);
cmd.Parameters.AddWithValue("#serviceCall", "No");
cmd.Parameters.AddWithValue("#partsShipment", "No");
cmd.Parameters.AddWithValue("#warranty", "No");
cmd.Parameters.AddWithValue("#cancel", "No");
cmd.Parameters.AddWithValue("#none", "No");
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw new Exception("Error on file update" + ex.Message);
}
finally
{
conn.Close();
}
}
}

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";

Why My jQuery Accordion remove after a Button click?

I want to use jQuery Accordion in my ASP.NEt Appliacation and it works but if I click on a Button in the Accordion then my Accordion remove :( Here my Code and two pitures...
aspx:
<link href="App_Theme/mainStyle.css" type="text/css" rel="Stylesheet" />
<script src="Scripte/jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="Scripte/jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script>
<link href="App_Theme/jquery-ui-1.8.23.custom.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$("#accordion").accordion();
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="manager" runat="server"></asp:ToolkitScriptManager>
<asp:UpdatePanel ID="update" runat="server">
<ContentTemplate>
<div id="accordion">
<h3><asp:Label ID="lblAbwesenheit" runat="server"/></h3>
<div>
<asp:Panel runat="server" ID="pn1" DefaultButton="btnAbwesenheitErzeugen">
<div id="Angaben" runat="server">
<table id="Angabentabelle" runat="server">
<tr>
<td><asp:Label ID="lblAbwesenheitBis" runat="server" /></td><td><asp:TextBox ID="txtAbwesenheitBis" runat="server" Enabled="false"></asp:TextBox>
<asp:ImageButton Width="20px" Height="20px" ID="imgbtnAbwesenheitBis" runat="server" ToolTip="Abwesenheit bis..." ImageUrl="~/App_Theme/Calender.ico" />
<asp:CalendarExtender ID="AbwesenheitBis" runat="server" TargetControlID="txtAbwesenheitBis"
Format="dd.MM.yyyy" PopupButtonID="imgbtnAbwesenheitBis"></asp:CalendarExtender>
</td>
</tr>
<tr>
<td><asp:Label ID="lblVertreter" runat="server" /></td>
<td>
<asp:TextBox ID="txtVertreter" runat="server"></asp:TextBox>
<asp:AutoCompleteExtender ID="AutoComlete" runat="server" TargetControlID="txtVertreter"
ServiceMethod="GetCompletionList" ServicePath="" Enabled="true"
DelimiterCharacters="" UseContextKey="true" MinimumPrefixLength="1" ></asp:AutoCompleteExtender>
(Suche nach Nachname)
</td>
</tr>
</table>
<asp:Button ID="btnAbwesenheitErzeugen" runat="server" Text="Erzeugen" OnClick="btnAbwesenheitErzeugen_Click" />
<br />
<br />
</div>
<HTMLEditor:Editor ID="htmlEditAbwesenheit" runat="server" Content="<% %>" />
</asp:Panel>
</div>
<h3><asp:Label ID="lblSignatur" runat="server" /></h3>
<div>
<HTMLEditor:Editor ID="htmlEditSignatur" runat="server" Content="<% %>" />
</div>
</div>
If I start my Page I see that:
and if I click on the Button then I see that...
Why My Accordion remove?
It's because your accordion is inside of an updatepanel. When you post back, everything inside your updatepanel is removed from the DOM and readded. Hence, the DOM element that was the accordion is gone. You need to call: $("#accordion").accordion(); after your postback.
one way you could do that is to do this:
<script type="text/javascript" language="javascript">
function SetupAccordion(){
$("#accordion").accordion();
}
$(document).ready(function () {
SetupAccordion();
if (typeof Sys.WebForms != 'undefined') {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(SetupAccordion);
}
});
</script>

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