Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client side issues with .NET

Status
Not open for further replies.

miteetall

Programmer
Jul 1, 2003
21
US
Just started doing .NET after years of "vintage" ASP. Seems like M$ is not making it easy to do client-side code within .NET. I really need to do some client-side dhtml and validation to prevent round-trips to the server and it looks like I am going to have dynamically render the javascript in a very ugly fashion in the Page.RegisterStartupScript. Anyone else as disappointed as I am?
 
If your looking to do JavaScript validation, look into the following objects:

- RequiredFieldValidator
- CompareValidator
- RangeValidator
- RegularExpressionValidator
- CustomValidator

Other client-side JavaScript events can be written into any asp server object by:

[Object].Attributes.Add("[Client-side Event]","[Scripting Function"]);

So, in answer to your question, no, I am not disappointed in the way M$ has dealt with this. The transition from traditional ASP to ASP.NET is not as easy as a lot of people would think. I would personally compare it to going from Perl to C++.

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
AChip's right...take a serious gander into ASP.NET's validation controls...they make cross-browser safe JavaScript for your WebForms, and are really easy to use.

If for some reason the out-of-box controls still don't get it done, you're free to roll your own solution.

Check out the MS dox at:
...or my column at:
 
Thanks for the assistance, guys - you're a great help :^)
 
Pulling my hair out on this one. I want to run a simple js function when a user selects an item from a drop down (I'm sure this is an ASP.NET issue).

This is my Javascript function:
Code:
function SetupUserType(UserType){
	if(UserType=='Customer'){
		lstNPCs.Enable=false;
		lstRoles.Enable=true;
	}else{
		lstNPCs.Enable=true;
		lstRoles.Enable=false;
	}
}

My call to the (js) file that contains the function
Code:
<script language="javascript" src="Local.js"></script>

My drop down listbox that contains the event:
Code:
<asp:dropdownlist OnSelectedIndexChanged="SetupUserType(this)" id="ddlUserType" runat="server">
<asp:ListItem Value="Customer" Selected="True">Customer</asp:ListItem>
<asp:ListItem Value="Employee">Employee</asp:ListItem>
</asp:dropdownlist>

This is the error (right at compile):
Code:
Compilation Error 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0117: 'ASP.Administrator_aspx' does not contain a definition for 'SetupUserType'

Source Error:
Line 30:
<asp:dropdownlist OnSelectedIndexChanged="SetupUserType(this)" id="ddlUserType" runat="server">
Line 31: <asp:ListItem Value="Customer" Selected="True">Customer</asp:ListItem>
Line 32: <asp:ListItem Value="Employee">Employee</asp:ListItem>

Any ideas? Let me know thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top