Valhalla Legends Archive

Programming => Web Development => Topic started by: CupHead on November 12, 2003, 02:45 PM

Title: [ASP .NET] Custom Controls
Post by: CupHead on November 12, 2003, 02:45 PM
Just as an example of what you can do with custom controls in ASP .NET, here are some screenshots of a login control I made that verifies through an Access database.  The UI stuff (colors, dimensions, fonts) are all controlled via style sheet rather than hard-coded.

(http://cuphead.valhallalegends.com/images/loggedout.png)
(http://cuphead.valhallalegends.com/images/loggedin.png)
Title: Re:[ASP .NET] Custom Controls
Post by: Adron on November 12, 2003, 02:58 PM
Is that a server-side or client-side thing? I typically associate a "control" with some type of user input thing that runs on the client and handles mouse/keyboard input + redrawing, but putting a login box client-side makes no sense..
Title: Re:[ASP .NET] Custom Controls
Post by: CupHead on November 12, 2003, 03:00 PM
ASP .NET kind of blurs the line.  You do the programming and it makes client-side what needs to be client-side and compiles for the server what needs to be done on the server.
Title: Re:[ASP .NET] Custom Controls
Post by: Grok on November 12, 2003, 03:17 PM
It's hard to blur anything when there are exactly two computers involved.  The client is running code in the browser, the server wherever the .NET CLR is running as host.

If there is only one computer involved, then you could say it is blurry.
Title: Re:[ASP .NET] Custom Controls
Post by: CupHead on November 12, 2003, 03:24 PM
There is only one computer involved at the moment--mine.  But the point that I was more trying to make is that you code everything at once, not necessarily writing code that is distinguishable from client or server.  .NET does all of the deciding for you.
Title: Re:[ASP .NET] Custom Controls
Post by: MyndFyre on November 12, 2003, 07:54 PM
Now, is that a full-fledged Custom Control, or is it just a User Control?

That's awesome if it's a full-fledged Custom Control, because with my experience, they're real bears to code, and ASP.NET does NOT decide for you what to do.  You have to program all of it, whereas a User Control is managed by the runtime (the .ascx file).

Nice-looking, though.  =)
Title: Re:[ASP .NET] Custom Controls
Post by: Adron on November 13, 2003, 04:54 AM
Quote from: CupHead on November 12, 2003, 03:24 PM
There is only one computer involved at the moment--mine.  But the point that I was more trying to make is that you code everything at once, not necessarily writing code that is distinguishable from client or server.  .NET does all of the deciding for you.

Doesn't that sound very much like regular scripting where you write either vbscript/javascript that runs on the server or vbscript/javascript that runs on the client? The difference would be that in regular scripting you yourself put either <% or <script> tags around your code, but I find it hard to believe that there isn't something you do to mark up what's going to be client side and what's going to be server side now anyway?
Title: Re:[ASP .NET] Custom Controls
Post by: CupHead on November 13, 2003, 07:53 AM
Quote from: Adron on November 13, 2003, 04:54 AM
Doesn't that sound very much like regular scripting where you write either vbscript/javascript that runs on the server or vbscript/javascript that runs on the client? The difference would be that in regular scripting you yourself put either <% or <script> tags around your code, but I find it hard to believe that there isn't something you do to mark up what's going to be client side and what's going to be server side now anyway?

The runat="server" parameter inside a tag is what lets the CLR know which code is server-side.  Also, .NET code is compiled on the server as opposed to being interpreted by a scripting engine.
Title: Re:[ASP .NET] Custom Controls
Post by: Banana fanna fo fanna on November 13, 2003, 07:41 PM
Basically, you can give a ListBox an onClick event and write code for it, and VB.NET knows to place the client-side onClick event on the client and the server-side handler on the server.
Title: Re:[ASP .NET] Custom Controls
Post by: Adron on November 14, 2003, 11:47 AM
Quote from: St0rm.iD on November 13, 2003, 07:41 PM
Basically, you can give a ListBox an onClick event and write code for it, and VB.NET knows to place the client-side onClick event on the client and the server-side handler on the server.

Does it also handle splitting

Sub OnClick
  label1 = val(text1) + val(text2)
  conn.execute "update table set value=" & label1
End Sub


into one part that runs on the client updating the label, and one part that runs on the server, updating the database?
Title: Re:[ASP .NET] Custom Controls
Post by: CupHead on November 14, 2003, 12:51 PM
What it would do in that situation is perform the label change server side so that after the form is submitted, the new page will have the updated label text.
Title: Re:[ASP .NET] Custom Controls
Post by: Adron on November 15, 2003, 12:16 PM
Quote from: CupHead on November 14, 2003, 12:51 PM
What it would do in that situation is perform the label change server side so that after the form is submitted, the new page will have the updated label text.

What if I want to do the label change client side and then submit the changed label to the server for storage?

edit:
More complex example: Think of how the "Post" button on the forum is first disabled, then the post is stored to the server. The Post button is disabled client side first, then the storage is done server side.
Title: Re:[ASP .NET] Custom Controls
Post by: CupHead on November 15, 2003, 01:17 PM
That would be done via a client side script (likely JavaScript) independent of the server controls.
Title: Re:[ASP .NET] Custom Controls
Post by: Adron on November 15, 2003, 06:36 PM
But didn't you say ASP.NET would do both client-side and server-side?
Title: Re:[ASP .NET] Custom Controls
Post by: Banana fanna fo fanna on November 15, 2003, 06:42 PM
Quote from: Adron on November 15, 2003, 06:36 PM
But didn't you say ASP.NET would do both client-side and server-side?

You can tell it what to run on the server and what on the client using the runat parameter of the listbox.
Title: Re:[ASP .NET] Custom Controls
Post by: Adron on November 15, 2003, 06:48 PM
Quote from: St0rm.iD on November 15, 2003, 06:42 PM
You can tell it what to run on the server and what on the client using the runat parameter of the listbox.

Of the listbox??
Title: Re:[ASP .NET] Custom Controls
Post by: quasi-modo on November 19, 2003, 04:19 PM
ASP.NET its self is server side. It does not do anything client side. You can integrate it with dhtml javascript or vbscript to get some desired affects but ASP.NET is server side. Now, I am not quite clear on the problem here. Is this a problem in how it is displaying or working? If it is not looking good why not just ditch creating the html attributes and use a lil css? Now about the runat commands. If you want to use an html element do not even put the runat in there and just make the html element. To make an html element runat the server then you use runat="server". But do not try to make a <asp:listbox run at the client level, just go ahead and do that in html.
Title: Re:[ASP .NET] Custom Controls
Post by: Banana fanna fo fanna on November 19, 2003, 04:56 PM
Quote from: peofeoknight on November 19, 2003, 04:19 PM
ASP.NET its self is server side. It does not do anything client side. You can integrate it with dhtml javascript or vbscript to get some desired affects but ASP.NET is server side. Now, I am not quite clear on the problem here. Is this a problem in how it is displaying or working? If it is not looking good why not just ditch creating the html attributes and use a lil css? Now about the runat commands. If you want to use an html element do not even put the runat in there and just make the html element. To make an html element runat the server then you use runat="server". But do not try to make a <asp:listbox run at the client level, just go ahead and do that in html.

It runs serverside, but decides what to send to the client and how to make it interact with the server correctly.
Title: Re:[ASP .NET] Custom Controls
Post by: CupHead on November 19, 2003, 05:02 PM
Quote from: peofeoknight on November 19, 2003, 04:19 PM
ASP.NET its self is server side. It does not do anything client side. You can integrate it with dhtml javascript or vbscript to get some desired affects but ASP.NET is server side. Now, I am not quite clear on the problem here. Is this a problem in how it is displaying or working? If it is not looking good why not just ditch creating the html attributes and use a lil css? Now about the runat commands. If you want to use an html element do not even put the runat in there and just make the html element. To make an html element runat the server then you use runat="server". But do not try to make a <asp:listbox run at the client level, just go ahead and do that in html.

There is no problem, I was just demonstrating the ASP .NET stuff.
Title: Re:[ASP .NET] Custom Controls
Post by: quasi-modo on November 19, 2003, 05:41 PM
Quote from: St0rm.iD on November 19, 2003, 04:56 PMIt runs serverside, but decides what to send to the client and how to make it interact with the server correctly.
The server outputs html generally with a little java script from time to time. I have not seen much java script other than the required feild validators. The whole point of using a server side language for scripting is to escape client side scripting which is not as accessable and not secure. You can type raw javascript, dhtml, css etc into your asp.net files after the </script><html> tags all you want and the server is not going to screw with it at all unless you are putting in includes or <asp: elements.

Here is the only server genorated java script that is on the default page for my clan's site
<script language="javascript" src="/aspnet_client/system_web/1_1_4322/WebUIValidation.js"></script>
Its just importing the validation sontrols etc.