Problem with ASP.Net control or JavaScript ???

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2007
Posts: 182
Reputation: Kusno is an unknown quantity at this point 
Solved Threads: 15
Kusno's Avatar
Kusno Kusno is offline Offline
Junior Poster

Problem with ASP.Net control or JavaScript ???

 
0
  #1
Nov 15th, 2007
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" />&nbsp;<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>
<aspropDownList ID="CmbDept" runat="server" Width="95px"></aspropDownList></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
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,080
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Solved Threads: 68
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Problem with ASP.Net control or JavaScript ???

 
0
  #2
Nov 15th, 2007
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:
  1. <script language="Javascript" type="text/javascript">
  2. function ChkAllCustomerClick()
  3. {
  4. var identity = document.forms.form1;
  5. if(identity.ChkAllCustomer.checked == true)
  6. {
  7. identity.TxtCustomerId.value = "";
  8. identity.TxtCustomerName.value = "";
  9. identity.CmdLocateCustomer.disabled = true;
  10. identity.CmbDept.disabled = false;
  11. }
  12. else
  13. {
  14. identity.CmdLocateCustomer.disabled = false;
  15. identity.CmbDept.disabled = true;
  16. }
  17. }
  18. </script>
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 182
Reputation: Kusno is an unknown quantity at this point 
Solved Threads: 15
Kusno's Avatar
Kusno Kusno is offline Offline
Junior Poster

Re: Problem with ASP.Net control or JavaScript ???

 
0
  #3
Nov 15th, 2007
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 .
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2396 | Replies: 2
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC