• Welcome to Valhalla Legends Archive.
 

[ASP .NET] Custom Controls

Started by CupHead, November 12, 2003, 02:45 PM

Previous topic - Next topic

CupHead

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.



Adron

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..

CupHead

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.

Grok

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.

CupHead

#4
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.

MyndFyre

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.  =)
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Adron

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?

CupHead

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.

Banana fanna fo fanna

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.

Adron

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?

CupHead

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.

Adron

#11
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.

CupHead

That would be done via a client side script (likely JavaScript) independent of the server controls.

Adron

But didn't you say ASP.NET would do both client-side and server-side?

Banana fanna fo fanna

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.