User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,234 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,762 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 1694 | Replies: 2
Reply
Join Date: Aug 2007
Location: Somewhere between heaven and hell
Posts: 111
Reputation: Kusno is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 8
Kusno's Avatar
Kusno Kusno is offline Offline
Junior Poster

Problem with ASP.Net control or JavaScript ???

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

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

  #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:
<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>
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  
Join Date: Aug 2007
Location: Somewhere between heaven and hell
Posts: 111
Reputation: Kusno is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 8
Kusno's Avatar
Kusno Kusno is offline Offline
Junior Poster

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

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 5:06 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC