| | |
Problem with ASP.Net control or JavaScript ???
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
Dear all,
I get problem with this ASP.Net form.
As you can see in the sources, I have Check Box (ChkAllCustomer), Combo Box (CmbDept) and Command Button (CmdLocateCustomer).
And to avoid postback I use JavaScript event instead of Anthem.Net.
Everytime user clicks ChkAllCustomer.Checked = true, CmdLocateCustomer enable property is set to false and CmbDept enable property is set to true.
In the other way, if ChkAllCustomer.Checked = false, CmdLocateCustomer enable property is set to true and CmbDept enable property is set to false.
Problem occurs when user clicks CmdLocateCustomer, but somehow CmdDept enable property is set to true manually where as there is not code in CmdLocateCustomer click event.
Please help me.
Thanks and regards,
Kusno.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="RptLoan.aspx.vb" Inherits="RptLoan" EnableSessionState="True"%>
<%@ OutputCache Location="Client" duration="5" varybyparam="none" %>
<!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>Loan</title>
<script language="Javascript" type="text/javascript">
function ChkAllCustomerClick()
{
if(form1.ChkAllCustomer.checked == true)
{
form1.TxtCustomerId.value = "";
form1.TxtCustomerName.value = "";
form1.CmdLocateCustomer.disabled = true;
form1.CmbDept.disabled = false;
}
else
{
form1.CmdLocateCustomer.disabled = false;
form1.CmbDept.disabled = true;
}
}
</script>
</head>
<body bgcolor="#ccccff">
<form id="form1" runat="server">
<table style="width: 572px; height: 80px;">
<tr>
<td style="width: 94px">
</td>
<td><asp:CheckBox ID="ChkAllCustomer" runat="server" Text="All Customer" Width="117px" Checked="True" onclick="ChkAllCustomerClick()" /></td>
</tr>
<tr>
<td style="width: 94px">
Customer :</td>
<td>
<input id="TxtCustomerId" runat="server" readonly="readonly" style="width: 63px" type="text" /> <asp:Button
ID="CmdLocateCustomer" runat="server" Text="..." Width="25px" Enabled="False" />
<input id="TxtCustomerName" runat="server" readonly="readonly" style="width: 246px" type="text" /></td>
</tr>
<tr>
<td style="width: 94px">
Department :
</td>
<td>
<asp
ropDownList ID="CmbDept" runat="server" Width="95px"></asp
ropDownList></td>
</tr>
</table>
</form>
</body>
Partial Class RptLoan
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
LoadDepartment()
End If
End Sub
Sub LoadDepartment()
CmbDept.Items.Clear()
CmbDept.Items.Add("--ALL--")
CmbDept.Items.Add("BD1")
CmbDept.Items.Add("BD2")
CmbDept.Items.Add("BD3")
CmbDept.SelectedIndex = 0
End Sub
Protected Sub CmdLocateCustomer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdLocateCustomer.Click
End Sub
End Class
I get problem with this ASP.Net form.
As you can see in the sources, I have Check Box (ChkAllCustomer), Combo Box (CmbDept) and Command Button (CmdLocateCustomer).
And to avoid postback I use JavaScript event instead of Anthem.Net.
Everytime user clicks ChkAllCustomer.Checked = true, CmdLocateCustomer enable property is set to false and CmbDept enable property is set to true.
In the other way, if ChkAllCustomer.Checked = false, CmdLocateCustomer enable property is set to true and CmbDept enable property is set to false.
Problem occurs when user clicks CmdLocateCustomer, but somehow CmdDept enable property is set to true manually where as there is not code in CmdLocateCustomer click event.
Please help me.
Thanks and regards,
Kusno.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="RptLoan.aspx.vb" Inherits="RptLoan" EnableSessionState="True"%>
<%@ OutputCache Location="Client" duration="5" varybyparam="none" %>
<!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>Loan</title>
<script language="Javascript" type="text/javascript">
function ChkAllCustomerClick()
{
if(form1.ChkAllCustomer.checked == true)
{
form1.TxtCustomerId.value = "";
form1.TxtCustomerName.value = "";
form1.CmdLocateCustomer.disabled = true;
form1.CmbDept.disabled = false;
}
else
{
form1.CmdLocateCustomer.disabled = false;
form1.CmbDept.disabled = true;
}
}
</script>
</head>
<body bgcolor="#ccccff">
<form id="form1" runat="server">
<table style="width: 572px; height: 80px;">
<tr>
<td style="width: 94px">
</td>
<td><asp:CheckBox ID="ChkAllCustomer" runat="server" Text="All Customer" Width="117px" Checked="True" onclick="ChkAllCustomerClick()" /></td>
</tr>
<tr>
<td style="width: 94px">
Customer :</td>
<td>
<input id="TxtCustomerId" runat="server" readonly="readonly" style="width: 63px" type="text" /> <asp:Button
ID="CmdLocateCustomer" runat="server" Text="..." Width="25px" Enabled="False" />
<input id="TxtCustomerName" runat="server" readonly="readonly" style="width: 246px" type="text" /></td>
</tr>
<tr>
<td style="width: 94px">
Department :
</td>
<td>
<asp
ropDownList ID="CmbDept" runat="server" Width="95px"></asp
ropDownList></td></tr>
</table>
</form>
</body>
Partial Class RptLoan
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
LoadDepartment()
End If
End Sub
Sub LoadDepartment()
CmbDept.Items.Clear()
CmbDept.Items.Add("--ALL--")
CmbDept.Items.Add("BD1")
CmbDept.Items.Add("BD2")
CmbDept.Items.Add("BD3")
CmbDept.SelectedIndex = 0
End Sub
Protected Sub CmdLocateCustomer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdLocateCustomer.Click
End Sub
End Class
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
try to explain a litter further on what needs to be done. It was a bit confusing.. or if you could provide a link?
Also, in your javascript, you're not declaring where the form sits. Set a var = document.forms.form1 and then call it everytime you need it. So this means change your javascript code to:
As for the rest of your code, keep in mind that when it is rendered on page, the ID for that code is different then you chose for it to runat server. View Source on your browser after running the code. Try not to use runat server controls if you don't have to. HTML controls are faster and obviously don't use server resources. So for your cmdLocate button or whatever, make that an HTML button and disabled="disabled" value. This should solve your problem.
Also, in your javascript, you're not declaring where the form sits. Set a var = document.forms.form1 and then call it everytime you need it. So this means change your javascript code to:
ASP.NET Syntax (Toggle Plain Text)
<script language="Javascript" type="text/javascript"> function ChkAllCustomerClick() { var identity = document.forms.form1; if(identity.ChkAllCustomer.checked == true) { identity.TxtCustomerId.value = ""; identity.TxtCustomerName.value = ""; identity.CmdLocateCustomer.disabled = true; identity.CmbDept.disabled = false; } else { identity.CmdLocateCustomer.disabled = false; identity.CmbDept.disabled = true; } } </script>
CmdLocateCustomer is used to open popup window and send value to it parent page.
In ASP.Net :
Protected Sub CmdLocateCustomer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdLocateCustomer.Click
Dim S As String = PopUpWindow("w_customer", "../../Browse/LocateCustomerMaster.aspx?CustomerId=form1.TxtCustomerId&CustomerName=form1.TxtCustomerName", 880, 550)
If ClientScript.IsClientScriptBlockRegistered("w") = False Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "w", S)
End If
End Sub
In Javascript :
function CmdLocateCustomer_onclick() {
var w = window.open('"../../Browse/LocateCustomerMaster.aspx?CustomerId=form1.TxtCustomerId&CustomerName=form1.TxtCustomerName','window');
w.focus();
}
I can use one of both scripts. But at least, I want to know why that problem occours when I use ASP.Net control
.
In ASP.Net :
Protected Sub CmdLocateCustomer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CmdLocateCustomer.Click
Dim S As String = PopUpWindow("w_customer", "../../Browse/LocateCustomerMaster.aspx?CustomerId=form1.TxtCustomerId&CustomerName=form1.TxtCustomerName", 880, 550)
If ClientScript.IsClientScriptBlockRegistered("w") = False Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "w", S)
End If
End Sub
In Javascript :
function CmdLocateCustomer_onclick() {
var w = window.open('"../../Browse/LocateCustomerMaster.aspx?CustomerId=form1.TxtCustomerId&CustomerName=form1.TxtCustomerName','window');
w.focus();
}
I can use one of both scripts. But at least, I want to know why that problem occours when I use ASP.Net control
![]() |
Similar Threads
- Video stream with ASP.NET (ASP.NET)
- ASP.NET button backcolor changing from code. (ASP.NET)
- ASP.NET - session objects Problem (ASP.NET)
- richtextbox in asp.net (ASP.NET)
- variables from javascript in asp.net (ASP.NET)
- Problem integrating ASP.NET 2.0 and HTML (ASP.NET)
- Clustered Cache in ASP.NET (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Help on DataList and Repeater Problem
- Next Thread: Problem with inserting photos into sql server in vb language
Views: 2396 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor asp asp.net bc30451 bottomasp.net browser button c# c#gridviewcolumn checkbox click commonfunctions compatible confirmationcodegeneration connection content courier css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist edit expose feedback flash form formatdecimal forms formview google grid gridview homeedition hosting iframe iis index javascript jquery list listbox login microsoft migration mono mouse mssql multistepregistration news numerical object objects panelmasterpagebuttoncontrols problem project radio richtextbox rotatepage save schoolproject search security session silverlight smartcard sql sql-server sqlserver2005 suse textbox theft tracking typeof unauthorized update validation vb.net video videos view virtualdirectory vista visualstudio web webdevelopemnt webservice xml youareanotmemberofthedebuggerusers






