|
I thought about it, but it would be too complex for my backend to handle, I think. I haven't put much thought into it, but I know I'd have to do page to page "marshalling" which doesn't really fit my model.
I've implemented a "GUI" toolkit in Java/JSP. Each page is a form, and each controlling GUI component uses the GET/POST-mechanism and various javascripts to signal events to the server components. And I maintain various states in the frame (my name for a web page), keep internationalizable information, data bound components etc. This model only works well inside page boundaries. I have been pondering though if I could cross the page boundaries and use frames/iframes, but as the project I'm working on doesn't require that, I'll keep it for a rainy sunday or something.
I finally managed to solve the problem using div and table. I got a nice looking list view/report in the end.
--
Please state the nature of your medical emergency.
|
|
|
|
|
Is there any way to have access to properites of user control,in my code behiind?
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Mazdak wrote:
Is there any way to have access to properites of user control,in my code behiind?
Yup, just define your usercontrol in your code behind as you would any normal control.
Remember your usercontrol is effectively the same as any of the "official" controls, no special treatment required.
e.g.
ASPX page:
...
<body>
<RKA:Header id="header" runat="server" CurrentSection="Garden Design" />
...
and then codebehind:
...
public class _template : System.Web.UI.Page
{
public rka_revamp._header header;
private void Page_Load(object sender, System.EventArgs e)
{
header.CurrentSection = true;
}...
|
|
|
|
|
Ages ago I read that when ASP.Net arrived we'd be able to "package" up the whole application so that it could be shipped off to a hosting provider without worrying about them stealing IP.
Did this eventuate? Or is it still on the wish list?
Gracias,
|
|
|
|
|
You can (of sorts). You can produce compiled code that can then be dropped into the /bin directory and off you go. For example, I've produced a few validation controls (they're on CodeProject), you can add the tags into the aspx pages directly, drop in the assembly and you're off. You could produce commercial controls in such a way and thus provide some IP protection.
Since its just IL it is pretty easy to reverse engineer, and there are tools that can produce C# code from a compiled assembly. Consequently, pre-compiling doesn't afford a huge amount of protection. If that's the case you'll need to look at obfuscation.
--
Paul
"I need the secure packaging of Jockeys. My boys need a house!"
- Kramer, in "The Chinese Woman" episode of Seinfeld
MS Messenger: paul@oobaloo.co.uk
Sonork: 100.22446
|
|
|
|
|
I have this code:
public void OnLogin(object sender, System.EventArgs e)
{
if(IsLoginCorrect(User.Text, Pass.Text))
{
FormsAuthentication.RedirectFromLoginPage(User.Text, false);
}
else
{
Error.Text = "Fel, försök igen!";
}
}
public bool IsLoginCorrect(string user, string password)
{
string connectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("mp219.mdb");
OleDbConnection connection = new OleDbConnection(connectString);
try
{
connection.Open();
StringBuilder builder = new StringBuilder();
builder.Append("SELECT COUNT(*) FROM Loin WHERE User = \'");
builder.Append(user);
builder.Append("\' AND CAST (rtrim (Password) as VARBINARY) = CAST(\'");
builder.Append(password);
builder.Append("\' as VARBINARY");
OleDbCommand cmd = new OleDbCommand(builder.ToString(), connection);
int count = (int)cmd.ExecuteScalar();
return (count > 0);
}
catch(Exception e)
{
Response.Write(e.ToString());
return false;
}
finally
{
connection.Close();
}
}
Whyyyyyyyyyyyyyyyyyyy does it throws an eception????????
Is it because the command string isn't correct?
I don't think so... I could be wrong... can you help me!!!???
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
What exception are you getting?
Before you criticize a man, walk a mile in his shoes. That way, when you do criticize him, you'll be a mile away and have his shoes.
|
|
|
|
|
I'm not so sure, but you mite need to set the command before opening the connection, as such:
OleDbCommand myCommand = new OleDbCommand(myScalarQuery, myConnection);
myCommand.Connection.Open();
myCommand.ExecuteScalar();
myConnection.Close();
Before you criticize a man, walk a mile in his shoes. That way, when you do criticize him, you'll be a mile away and have his shoes.
|
|
|
|
|
Rickard Andersson wrote:
FROM Loin WHERE User = \'"); builder.Append(user); builder.Append("\' AND CAST (rtrim (Password) as VARBINARY) = CAST(\'"); builder.Append(password); builder.Append("\' as VARBINARY");
Why have you put the character-escape \ into this? A single quote does not need to be escaped, does it?
Anyway I just put your code into C# and no compiler errors came up without the \ bits. Maybe thoses \s are going through to SQL itself and causing a problem.
|
|
|
|
|
Oh... does are not meaning to be there!
I tried if that was that caused the exception, but it wasn't....
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
Is it because the command string isn't correct?
I don't think so... I could be wrong... can you help me!!!???
Oh wait I just figured it out. You are missing a closing bracket on the end of your command string. Change builder.Append("\' as VARBINARY"); to builder.Append("\' as VARBINARY)");
Helpful tip #1 for SQL: Always Response.Write your command strings out to check them. Then copy and paste that string into Query Analyzer and run it to pick up any errors. Best debugging method I have ever learnt for SQL
|
|
|
|
|
Paul Watson wrote:
Oh wait I just figured it out. You are missing a closing bracket on the end of your command string. Change builder.Append("\' as VARBINARY"); to builder.Append("\' as VARBINARY)");
Oh!
So I did a miss in the command string anyway!!!
Paul Watson wrote:
Helpful tip #1 for SQL: Always Response.Write your command strings out to check them. Then copy and paste that string into Query Analyzer and run it to pick up any errors. Best debugging method I have ever learnt for SQL
Query Analyzer?
Is it an built in tool or what in Access 2000?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Rickard Andersson wrote:
Is it an built in tool or what in Access 2000?
SQL Server tool. Just do a query ("fråga" in Swedish) in Access
--
Please state the nature of your medical emergency.
|
|
|
|
|
Jörgen Sigvardsson wrote:
("fråga" in Swedish)
Nice!
Then I know how to debug a SQL query in Access 2000!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I am loosing my mind here and want to make sure that I am not simply trying to do somehting that can't be done, allthough I can't belive that it can't be done really.
Problem:
I want to keep a simple counter on my website that tracks how many people are logged in. The value of this counter should be placed onto a label control when a page is loaded.
Proposed Solution:
I have this code in my global.asax file...
Public Class Global
Inherits System.Web.HttpApplication
Protected Shared m_ActiveUsers As Integer
#Region " Component Designer Generated Code "
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Private components As System.ComponentModel.IContainer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
#End Region
Public Shared ReadOnly Property ActiveUsers() As Integer
Get
Return m_ActiveUsers
End Get
End Property
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Application.Lock()
m_ActiveUsers = 0
Application.UnLock()
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Application.Lock()
m_ActiveUsers = m_ActiveUsers + 1
Application.UnLock()
End Sub
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires at the beginning of each request
End Sub
Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires upon attempting to authenticate the use
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Fires when an error occurs
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
Application.Lock()
m_ActiveUsers = m_ActiveUsers - 1
Application.UnLock()
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application ends
End Sub
End Class
I have this code in my WebForm.aspx.vb file
Private Sub Page_Load(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles MyBase.Load
lblVisitors.Text = Global.ActiveUsers.ToString + " Visitors"
End Sub
The problem is that the label contents are ALWAYS blank!
Any ideas out there as to what I am doing wrong?
Help me please before I decide to do something drastic!
|
|
|
|
|
Ok, took a while but I found out aparently what my darn problem was...
I never hit the rebuild button
|
|
|
|
|
Okay... my turn...
Is there a better way of doing this?
<script></script>
<script for="ddlPlayer" event="onfocus"></script>
<script for="cbExistAsGM" event="onfocus"></script>
<script for="cbExistAsTO" event="onfocus"></script>
<script for="tbFullName" event="onfocus"></script>
<script for="tbNick" event="onfocus"></script>
<script for="tbEmail" event="onfocus"></script>
<script for="tbLocation" event="onfocus"></script>
<script for="cbNewAsGM" event="onfocus"></script>
<script for="cbNewAsTO" event="onfocus"></script>
<script for="cbNewAsTMC" event="onfocus"></script>
I don't want to use onfocus="ChangeRB();" because they're actually <asp:...> tags, which have a tendency to deal with events on the server. So what I'm looking for really is a way to say "execute this script when focus moves to any of these controls..."
This works fine as it is but it seems like a waste of bandwidth to me so any abbreviated way of doing it would be a bonus.
Paul
|
|
|
|
|
Paul Riley wrote:
=
<script for="cbNewAsTMC" event="onfocus">ChangeRB(false);</script>
minus 8 bytes
Paul Riley wrote:
I don't want to use onfocus="ChangeRB();" because they're actually <asp:...> tags, which have a tendency to deal with events on the server. So what I'm looking for really is a way to say "execute this script when focus moves to any of these controls..."
Why not? Thats what ASP.NET uses onclick="__DoPostBack()" in their controls...The function gets control control of what is going to be done.
Before you criticize a man, walk a mile in his shoes. That way, when you do criticize him, you'll be a mile away and have his shoes.
|
|
|
|
|
leppie wrote:
minus 8 bytes
Hmmm... I prefer to keep the commenting in there, just in case someone has scripting blocked or for some reason is using a browser that doesn't support it.
leppie wrote:
Why not? Thats what ASP.NET uses onclick="__DoPostBack()"
I had a problem doing this with a text box onchange but looking again, I might have done something stupid like using OnTextChange because I can't see why it would go wrong.
Ho hum, I'll try it that way then
Paul
|
|
|
|
|
Using "onfocus=" doesn't work.
For some obscure reason that I can't see, it doesn't work at all for the drop down list. It does work for the textboxes but the checkboxes are wrapped with a SPAN tag which gets the onfocus; no use to me.
Sigh! Oh well. Back to the inefficient method unless someone has something else...
Paul
|
|
|
|
|
Paul Riley wrote:
It does work for the textboxes but the checkboxes are wrapped with a SPAN tag which gets the onfocus; no use to me.
Why are you doing that?
<input onfocus="function()" will do it, not?
Before you criticize a man, walk a mile in his shoes. That way, when you do criticize him, you'll be a mile away and have his shoes.
|
|
|
|
|
NO! I'm using WebForms so the declaration is
<asp:CheckBox id="cbNewAsTMC" runat="server"></asp:CheckBox>
Paul
|
|
|
|
|
Paul Riley wrote:
NO! I'm using WebForms so the declaration is
<asp:checkbox id="cbNewAsTMC" runat="server">
Just override RenderContents() and add the event to the input tag that you will have todo yourself (its only one line, just check the output in a webpage and copy/paste). The style will still be preserved.
Hope this helps
Before you criticize a man, walk a mile in his shoes. That way, when you do criticize him, you'll be a mile away and have his shoes.
|
|
|
|
|
Oooo, now that's an idea! I haven't played with WebControls yet but that's a good plan. Cheers leppie.
Paul
|
|
|
|
|
Paul Riley wrote:
I haven't played with WebControls yet but that's a good plan.
Yes, its very easy
Just make your control in your favourite HTML editor. Copy the HTML to C# strings, make some variables and use String.Format() to assign in HTML. As easy as pie (not that I ever made one, but at least I'm eating one now )!
Cheers
Before you criticize a man, walk a mile in his shoes. That way, when you do criticize him, you'll be a mile away and have his shoes.
|
|
|
|