CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 4/29/2004 9:02:25 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 8 Views: 38 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
9 Items, 1 Pages 1 |< << Go >> >|
davidyang
Asp.Net User
How to hide client script in web custom controls?4/29/2004 9:02:25 PM

0/0

We know that a goog web custom control need lots of client script to support rich functions.
But when I use some 3-party web custom controls, I can't find any scripts on the source codes in my web pages.
normally, we need to include the script file in web pages. looks like:
<script language="javascript" src="xxxxx.js">
or
in server side, using RegisterClientScriptBlock to send client script to client side. But in this way, user can watch the script code.

but what I found is just
<script language="javascript src="controlnamepage.aspx?3.5.6.21456">

The controlnamepage.aspx is what the provider ask user to copy it to user's project.
But this controlnamepage.aspx only contain one line:
<%@ Page AutoEventWireup="false" Inherits="xxxxxx.xxxxxx.controlnamepage" %>

Is there anyone who has any idea about it?

Thanks a lot!!!!!!

David
master4eva
Asp.Net User
Re: How to hide client script in web custom controls?4/29/2004 9:40:50 PM

0/0

It is rather simple. The true of that provider page can actually be found in the server control's library. It is all about inheritance. It is the same as having the following code:

public class A : CollectionBase {}
public class B : A {}

In effect, what they have done is have the following code in their library:

public abstract class SomePage : Page {
// class A in the above example
}

However, an ASP.NET page by itself is a class! It is converted into a class at runtime by the parser. So the page will be named "ServingPage" and therefore (by "default"), it should look like this:

public class ServingPage_aspx : Page {
// nothing yet
}

But what that <%@ Page %> declarative does is tells that the class will not inherit from the Page class. Instead, it will compile from the specified class. Therefore, it will rather create code like so:

public class ServingPage_aspx : SomePage {
// serves as class B in first example
}

And that page does not contain "just one line of code". In fact, all its code is truely found in the class it is inheritting from.
-- Justin Lovell
davidyang
Asp.Net User
Re: How to hide client script in web custom controls?4/30/2004 2:18:09 PM

0/0

Thanks a lot, master4eva. Actually, I know the mechanism but I can't implement it by myself.
I'm now developing a web custom control and like to use the same mechanism. This is what I have done:
1: create a project for the custom control . name space is : webcontrols. control name is superGrid. So the project includes superGrid.cs,SuperGridDesigner.cs , SuperGrid.resx and SuperGridWebPage.cs. I put java script in SuperGrid.resx.
In SuperGridWebPage.cs, Code is
public class SuperGridWebPage: System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
ResourceManager manager = new ResourceManager( this.GetType() );
String script = manager.GetResourceSet (System.Globalization.CultureInfo.CurrentCulture, true, true).GetString("ClientScript");
Response.Write(script);
}
}
2:created a test web project which include a test page.
Imported superGird in toolbox and drop it on test page.
Because superGridScript.aspx is supposely provided by vendor, so I can't touch it.
The page contains only one line:
<%@ Page AutoEventWireup="false" Inherits="WebControls.SuperGridWebPage" %>
3: it seems it should work fine. But it didn't.

Could you help me to tell which step is wrong?

Thanks!!!!

David

master4eva
Asp.Net User
Re: How to hide client script in web custom controls?4/30/2004 3:19:37 PM

0/0

The issue is with step one. What I do is pure reflection like so:

try {
Assembly assembly = Assembly.GetExecutingAssembly();
Stream stream = assembly.GetManifestResourceStream("yourfullnamespace.yourfilename");
StreamReader reader = new StreamReader(stream);

return reader.ReadToEnd();
}
catch (Exception ex) {
throw new MissingManifestResourceException(path, ex);
}

And on top of that, the resource must be set as an embedded resource. If you have VS.NET, click on your resource file and then on the properties, select as "embedded resource". If you are compiling from the command line, then you will have to add the appropiate arguments.
-- Justin Lovell
master4eva
Asp.Net User
Re: How to hide client script in web custom controls?4/30/2004 3:20:44 PM

0/0

BTW -- that was a template from one of my projects. What you have to do is Response.Write the content and then Response.End.
-- Justin Lovell
davidyang
Asp.Net User
Re: How to hide client script in web custom controls?4/30/2004 6:43:29 PM

0/0

master4eva, I debuged my step 1 codes. Every things worked well. I can get script for resource file and Response.write worked well. BUT, client side can't approch the script.
It drives me crazy.
I still think there are something wrong in my step 1 code.
I can get the script successfully.
master4eva
Asp.Net User
Re: How to hide client script in web custom controls?4/30/2004 7:50:27 PM

0/0

And did you put the Response.ContentType = "text/javascript"?
-- Justin Lovell
davidyang
Asp.Net User
Re: How to hide client script in web custom controls?5/3/2004 6:34:14 PM

0/0

Yes. I put it.
davidyang
Asp.Net User
Re: How to hide client script in web custom controls?5/6/2004 2:07:33 PM

0/0

I got it. It works successfully! Thanks a lot , master4eva!
9 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Mastering Web Development with Microsoft Visual Studio 2005 Authors: John Paul Mueller, Pages: 822, Published: 2005
Pro ASP. Net 3. 5 Server Controls and AJAX Components Authors: Rob Cameron, Dale Michalk, Pages: 740, Published: 2008
Pro ASP.NET 2.0 in VB 2005: From Professional to Expert Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006
Professional Visual Studio 2005 Authors: Andrew Parsons, Nick Randolph, Pages: 869, Published: 2006
Essential SharePoint: Microsoft Office Document Collaboration in Action Authors: Jeff Webb, Pages: 310, Published: 2005
ASP.NET AJAX Programmer's Reference: With ASP.NET 2.0 Or ASP.NET 3.5 Authors: Shahram Khosravi, Pages: 1522, Published: 2007
Mastering ASP.NET with C# Authors: A. Russell Jones, Pages: 816, Published: 2002
The Visual Basic Object and Component Handbook Authors: Peter Vogel, Pages: 668, Published: 2000

Web:
Working with Client-Side Script With classic ASP, adding data-driven, custom client-side script was simple, ... NET, since the validator Web controls provide client-side form validation ...
CodeProject: Progressbar for long running scripts. Free source ... Aug 21, 2008 ... Write("StartShowWait();"); if (!IsPostBack) { //Hide if first ... A user interface web control for building conditions suitable for ...
vbCity/DevCity.NET Forums :: .NET :: ASP.NET :: FAQ :: Handling ... Handling Web Page controls visibility with client-side code .... Frequently Used Client Side Scripts where you can learn more about handling ...
ASP.NET AJAX Development Approach Part 3 Jul 30, 2008 ... Web.UI.ScriptControl server control, Sys.UI.Control client class – If you don’t need to inherit from a different class, have your custom ...
Inside Microsoft: Client Script Callbacks in ASP.NET Part II In fact, that’s the approach I’ll take here, using the custom control merely as an ..... Overall client script callbacks are a welcome addition to ASP. ...
Automatic Control Prefixes like _ctl0 embedded my custom control in my web page. ... registering a client-side script that calls the function(s) you are calling ...
Register Client Script Web Assembly in GAC, Page Inherits Strongly Named Assembly? ... ASP2.0 Wizard control, attach client script on FinishButtonClick ...
using javascript functions in asp custom control - ASP.NET Forums I have created a custom web server (mycomponent.ascx). ... className = "hide"; } }  *Work rotating roster?   ...
DEV300 Building ASP.NET Server Controls Part I: The Basics Handling The Client Event. Controls render script handler ... Use a WebControlLibrary project to create custom compiled controls; Initialize the Version ...
Safari Books Online - 0735615829 - Developing Microsoft ASP.NET ... Web Forms—the page and control framework at the heart of ASP. ... Control Life Cycle, Events, and Postback > Generating Client-Side Script for Postback ...




Search This Site:










visible property of a labelcontrol

linkbutton in a control force a click on a page

godaddy and sql server

panel content gone when editing parent properties

about datagrid control build problem....

problem with panels inside usercontrols

the best service of asp .net 2.0

dispose (by the book) causes infinite loop!

attribute of custom control - surely there is away

composite control base question

creating a provider model

i cant use my computer as web server

custom webcontrol - "error creating control" error in designview

multi-assembly dll guru required

quick ad 2003 questions

options for creating rich email body

what firewall or other security to use?

gridview and header

asp:dropdownlist

generate css

web custom control with radiobuttons

inamingcontainer. (why unique names ????)

custom validation control

question on hosting

retrieving auto-generated dhtml client id server side?

html analyzer

how do i create a composite control w/ htmlanchor control and capture the onserverclick event in my main page?

loadpostdata in use....

controls.add in composite control that inherits another control

namespace in dll

  Privacy | Contact Us
All Times Are GMT