Showing posts with label custom. Show all posts
Showing posts with label custom. Show all posts

Saturday, March 31, 2012

the asp.net application doesnt compile it self under the /bin directory, where it is?

I want to use my custom control (.cs) in my web application. Custom control
is in the same assembly as my application. I want to know the name of the
assembly (.dll) file so i can add it's <@dotnet.itags.org.Pegister Assembly="abc.dll"> name.
But in asp.net 2.0 i can't find the assembly. It is not compiled under the
/bin folder. Where it is, or how can i give a reference to it?re:
> I want to use my custom control (.cs) in my web application.

Custom controls aren't located in *.cs files.
Classes are included in *.cs files.

Can you clarify what you are looking for ?

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Espaol : http://asp.net.do/foros/
======================================
"Umut Tezduyar" <umut@dotnet.itags.org.tezduyar.com> wrote in message
news:uxcKX7t6FHA.2036@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
> I want to use my custom control (.cs) in my web application. Custom control is in the
> same assembly as my application. I want to know the name of the assembly (.dll) file so
> i can add it's <@dotnet.itags.org.Pegister Assembly="abc.dll"> name. But in asp.net 2.0 i can't find the
> assembly. It is not compiled under the /bin folder. Where it is, or how can i give a
> reference to it?
I mean, not the *.ascx (User controls), custom control.

Let me ask my question in this way: I can't add my custom control in a web
page because i don't know what to write in the <@dotnet.itags.org.Page Assembly=''> register
tag.

"Juan T. Llibre" <nomailreplies@dotnet.itags.org.nowhere.com> wrote in message
news:Oo7QLKu6FHA.2036@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
> re:
>> I want to use my custom control (.cs) in my web application.
> Custom controls aren't located in *.cs files.
> Classes are included in *.cs files.
> Can you clarify what you are looking for ?
>
> Juan T. Llibre, ASP.NET MVP
> ASP.NET FAQ : http://asp.net.do/faq/
> ASPNETFAQ.COM : http://www.aspnetfaq.com/
> Foros de ASP.NET en Espaol : http://asp.net.do/foros/
> ======================================
> "Umut Tezduyar" <umut@dotnet.itags.org.tezduyar.com> wrote in message
> news:uxcKX7t6FHA.2036@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
>>
>> I want to use my custom control (.cs) in my web application. Custom
>> control is in the same assembly as my application. I want to know the
>> name of the assembly (.dll) file so i can add it's <@dotnet.itags.org.Pegister
>> Assembly="abc.dll"> name. But in asp.net 2.0 i can't find the assembly.
>> It is not compiled under the /bin folder. Where it is, or how can i give
>> a reference to it?
OK...

For that, check out :
http://support.microsoft.com/defaul...kb;en-us;321749

The proper tag is :
<%@dotnet.itags.org. Register TagPrefix="Custom" Namespace="CustomControlNamespace" Assembly= "CustomControl" %
Custom is an alias that you associate with a namespace.
CustomControlNamespace is a namespace in which classes of an assembly are enclosed.
CustomControl is the name of the assembly file without an extension (.dll).


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Espaol : http://asp.net.do/foros/
======================================
"Umut Tezduyar" <umut@dotnet.itags.org.tezduyar.com> wrote in message news:uI%23L45u6FHA.1000@dotnet.itags.org.tk2msftngp13.phx.gbl...
>I mean, not the *.ascx (User controls), custom control.
>
> Let me ask my question in this way: I can't add my custom control in a web
> page because i don't know what to write in the <@dotnet.itags.org.Page Assembly=''> register
> tag.
>
>
> "Juan T. Llibre" <nomailreplies@dotnet.itags.org.nowhere.com> wrote in message
> news:Oo7QLKu6FHA.2036@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
>> re:
>>> I want to use my custom control (.cs) in my web application.
>>
>> Custom controls aren't located in *.cs files.
>> Classes are included in *.cs files.
>>
>> Can you clarify what you are looking for ?

>> "Umut Tezduyar" <umut@dotnet.itags.org.tezduyar.com> wrote in message
>> news:uxcKX7t6FHA.2036@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
>>>
>>> I want to use my custom control (.cs) in my web application. Custom
>>> control is in the same assembly as my application. I want to know the
>>> name of the assembly (.dll) file so i can add it's <@dotnet.itags.org.Pegister
>>> Assembly="abc.dll"> name. But in asp.net 2.0 i can't find the assembly.
>>> It is not compiled under the /bin folder. Where it is, or how can i give
>>> a reference to it?
On Wed, 16 Nov 2005 10:52:05 -0800, "Umut Tezduyar"
<umut@dotnet.itags.org.tezduyar.com> wrote:

>I want to use my custom control (.cs) in my web application. Custom control
>is in the same assembly as my application.

Is this 2.0? (I assume so based on your previous questions). Your
custom control must be in App_Code, correct?

Something like this:

namespace OTC
{
public class MyCustomControl : WebControl
{
protected override void Render(HtmlTextWriter writer)
{
writer.Write("This is my custom control");
base.Render(writer);
}
}
}

>I want to know the name of the
>assembly (.dll) file so i can add it's <@dotnet.itags.org.Pegister Assembly="abc.dll"> name.
>But in asp.net 2.0 i can't find the assembly. It is not compiled under the
>/bin folder. Where it is, or how can i give a reference to it?

ASP.NET builds App_Code as a separate assembly, and the runtime will
recognize "App_Code" as an assembly name in a reference directive.

<%@dotnet.itags.org. Register Assembly="App_Code" TagPrefix="otc" Namespace="OTC" %
...

<otc:MyCustomControl runat="Server" id="boo" /
--
Scott
http://www.OdeToCode.com/blogs/scott/

the asp.net application doesn't compile it self under the /bin directory, where it is

I want to use my custom control (.cs) in my web application. Custom control
is in the same assembly as my application. I want to know the name of the
assembly (.dll) file so i can add it's <@dotnet.itags.org.Pegister Assembly="abc.dll"> name.
But in asp.net 2.0 i can't find the assembly. It is not compiled under the
/bin folder. Where it is, or how can i give a reference to it?re:
> I want to use my custom control (.cs) in my web application.
Custom controls aren't located in *.cs files.
Classes are included in *.cs files.
Can you clarify what you are looking for ?
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Espaol : http://asp.net.do/foros/
======================================
"Umut Tezduyar" <umut@dotnet.itags.org.tezduyar.com> wrote in message
news:uxcKX7t6FHA.2036@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
> I want to use my custom control (.cs) in my web application. Custom contro
l is in the
> same assembly as my application. I want to know the name of the assembly (
.dll) file so
> i can add it's <@dotnet.itags.org.Pegister Assembly="abc.dll"> name. But in asp.net 2.0 i c
an't find the
> assembly. It is not compiled under the /bin folder. Where it is, or how ca
n i give a
> reference to it?
I mean, not the *.ascx (User controls), custom control.
Let me ask my question in this way: I can't add my custom control in a web
page because i don't know what to write in the <@dotnet.itags.org.Page Assembly=''> register
tag.
"Juan T. Llibre" <nomailreplies@dotnet.itags.org.nowhere.com> wrote in message
news:Oo7QLKu6FHA.2036@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
> re:
> Custom controls aren't located in *.cs files.
> Classes are included in *.cs files.
> Can you clarify what you are looking for ?
>
> Juan T. Llibre, ASP.NET MVP
> ASP.NET FAQ : http://asp.net.do/faq/
> ASPNETFAQ.COM : http://www.aspnetfaq.com/
> Foros de ASP.NET en Espaol : http://asp.net.do/foros/
> ======================================
> "Umut Tezduyar" <umut@dotnet.itags.org.tezduyar.com> wrote in message
> news:uxcKX7t6FHA.2036@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
>
OK...
For that, check out :
http://support.microsoft.com/defaul...kb;en-us;321749
The proper tag is :
<%@dotnet.itags.org. Register TagPrefix="Custom" Namespace="CustomControlNamespace" Assembly=
"CustomControl" %>
Custom is an alias that you associate with a namespace.
CustomControlNamespace is a namespace in which classes of an assembly are en
closed.
CustomControl is the name of the assembly file without an extension (.dll).
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Espaol : http://asp.net.do/foros/
======================================
"Umut Tezduyar" <umut@dotnet.itags.org.tezduyar.com> wrote in message news:uI%23L45u6FHA.1000@dotnet.itags.org.tk2msftngp13.p
hx.gbl...
>I mean, not the *.ascx (User controls), custom control.
>
> Let me ask my question in this way: I can't add my custom control in a web
> page because i don't know what to write in the <@dotnet.itags.org.Page Assembly=''> registe
r
> tag.
>
>
> "Juan T. Llibre" <nomailreplies@dotnet.itags.org.nowhere.com> wrote in message
> news:Oo7QLKu6FHA.2036@dotnet.itags.org.TK2MSFTNGP14.phx.gbl...
On Wed, 16 Nov 2005 10:52:05 -0800, "Umut Tezduyar"
<umut@dotnet.itags.org.tezduyar.com> wrote:

>I want to use my custom control (.cs) in my web application. Custom control
>is in the same assembly as my application.
>
Is this 2.0? (I assume so based on your previous questions). Your
custom control must be in App_Code, correct?
Something like this:
namespace OTC
{
public class MyCustomControl : WebControl
{
protected override void Render(HtmlTextWriter writer)
{
writer.Write("This is my custom control");
base.Render(writer);
}
}
}

>I want to know the name of the
>assembly (.dll) file so i can add it's <@dotnet.itags.org.Pegister Assembly="abc.dll"> name.
>But in asp.net 2.0 i can't find the assembly. It is not compiled under the
>/bin folder. Where it is, or how can i give a reference to it?
>
ASP.NET builds App_Code as a separate assembly, and the runtime will
recognize "App_Code" as an assembly name in a reference directive.
<%@dotnet.itags.org. Register Assembly="App_Code" TagPrefix="otc" Namespace="OTC" %>
...
<otc:MyCustomControl runat="Server" id="boo" />
Scott
http://www.OdeToCode.com/blogs/scott/

The benefit of events??

Hi,

I am trying to determine the best use for custom events.

Here is mytest code. (I know that the arguments are inappropriate for event handlers ... but this is just a test.) The code simply updates a Label control on the webform:

Namespace test

Public Class events
Inherits System.Web.UI.Page

Protected lblMessage As System.Web.UI.WebControls.Label

Protected Delegate Sub EventHandler( ByRef comment As String )
Protected Event Event1 As EventHandler

Protected Sub Page_Init( ByVal sender As System.Object, ByVal eArgs As System.EventArgs ) Handles MyBase.Init
AddHandler Me.Event1, AddressOf Me.Event1Handler
AddHandler Me.Event1, AddressOf Me.Event2Handler
End Sub

Protected Sub Page_Load( ByVal sender As System.Object, ByVal eArgs As System.EventArgs ) Handles MyBase.Load
If Not Page.IsPostBack Then
Dim toSay As String = "raised as event"
RaiseEvent Event1( toSay )
RaiseEvent Event1( toSay )
Event1Handler( "called as method" )
End If
End Sub

Private Sub Event1Handler( ByRef comment As String )
lblMessage.Text &= "Event1Handler: " & comment
comment &= ", changed by Event1Handler"
End Sub

Private Sub Event2Handler( ByRef comment As String )
lblMessage.Text &= "Event2Handler: " & comment
comment &= ", changed by Event2Handler"
End Sub

End Class

End Namespace

In terms of functionality, there doesn't seem to be any difference between raising an event [RaiseEvent Event1( "raised as event" )] and "calling" the event handler directly [Event1Handler( "called as method" )].

In my test, they did exactly the same thing. I can see only two benefits to using events.

First, I can dynamically attach one or more methods to an event. This helps in implementing certain design patterns.

Second, a raised event need not be handled at all. Whereas calling a missing method generates an exception, raising a custom event with no handler is okay.

Am I missing the importance of events?Well,

in your example Event1Handler is private method (it is event handler after all).

Generally events should have corresponding protected method <On>EventName which is used to raise the event by calling it.

For example you have :


Protected Event Event1 As EventHandler

which would have corresponding method:


Protected Sub OnEvent1(comment As String)
RaiseEvent Event1(comment1)
End Sub

which would provide a way for inherited classes to raise the event by calling the inherited method.


OnEvent1("Something")

So it is the inheritance thing in picture as well.

And usually event should always provide the sender of the event (object that raises the event) so that event's consumer would have straight access to the object that is raising the event (another alternative is of course just give enough event arguments)

C# provides a way to check if event has listeners attached so that event wouldn't be raised if there are no listeners (to save some horsepower ;-) ). VB doesn't currently have this feature.

Wednesday, March 28, 2012

The best way to parse an html file?

Hi,
I have a html file file that I want to parse with ASP.NET to retreive the
value of a custom tag. Let's say that the average html file is about 30 ko.
Once the html file is loaded and converted into a single string, I'm using
for now is two string.indexOf to find the begin and the end of the desired
tag and then a string.substring to extract the data. I'm not using regular
expressions since I know exactly what are the tags to find.
My function goes like this:
private string ParseHtml(string html)
{
html = html.Replace("\r\n","");
int begin = html.IndexOf("%%StartGetHtml%%");
int end = html.IndexOf("%%EndGetHtml%%",begin);
int begin2, end2;
string str = null;
if (begin > 0 && end > 0)
{
// Gets the beginning of the tag
begin2 = html.IndexOf("<",begin);
// Gets the end of the tag
end2 = html.IndexOf(">",end-3);
if (begin2 < end2 && end2 < end)
{
// Gets the tag
str = html.Substring(begin2,end-begin2);
}
}
return str;
}
Is this the fastest way or there could be a better way to do this?
Thanks
Stephane
Stephane wrote:

> I have a html file file that I want to parse with ASP.NET to retreive the
> value of a custom tag. Let's say that the average html file is about 30 ko
.
> Once the html file is loaded and converted into a single string, I'm using
> for now is two string.indexOf to find the begin and the end of the desired
> tag and then a string.substring to extract the data. I'm not using regular
> expressions since I know exactly what are the tags to find.
> My function goes like this:
> private string ParseHtml(string html)
> {
> html = html.Replace("\r\n","");
> int begin = html.IndexOf("%%StartGetHtml%%");
> int end = html.IndexOf("%%EndGetHtml%%",begin);
> int begin2, end2;
> string str = null;
> if (begin > 0 && end > 0)
> {
> // Gets the beginning of the tag
> begin2 = html.IndexOf("<",begin);
> // Gets the end of the tag
> end2 = html.IndexOf(">",end-3);
> if (begin2 < end2 && end2 < end)
> {
> // Gets the tag
> str = html.Substring(begin2,end-begin2);
> }
> }
> return str;
> }
> Is this the fastest way or there could be a better way to do this?
If those string processing attempts suffice for you then use them but in
general if you want to parse HTML you might want to check SGMLReader, see
http://www.gotdotnet.com/community/...uery=sgmlreader
Martin Honnen
http://JavaScript.FAQTs.com/

The best way to parse an html file?

Hi,

I have a html file file that I want to parse with ASP.NET to retreive the
value of a custom tag. Let's say that the average html file is about 30 ko.
Once the html file is loaded and converted into a single string, I'm using
for now is two string.indexOf to find the begin and the end of the desired
tag and then a string.substring to extract the data. I'm not using regular
expressions since I know exactly what are the tags to find.
My function goes like this:

private string ParseHtml(string html)
{
html = html.Replace("\r\n","");
int begin = html.IndexOf("%%StartGetHtml%%");
int end = html.IndexOf("%%EndGetHtml%%",begin);
int begin2, end2;
string str = null;
if (begin > 0 && end > 0)
{
// Gets the beginning of the tag
begin2 = html.IndexOf("<",begin);
// Gets the end of the tag
end2 = html.IndexOf(">",end-3);
if (begin2 < end2 && end2 < end)
{
// Gets the tag
str = html.Substring(begin2,end-begin2);
}
}
return str;
}

Is this the fastest way or there could be a better way to do this?

Thanks

Stephane
Stephane wrote:

> I have a html file file that I want to parse with ASP.NET to retreive the
> value of a custom tag. Let's say that the average html file is about 30 ko.
> Once the html file is loaded and converted into a single string, I'm using
> for now is two string.indexOf to find the begin and the end of the desired
> tag and then a string.substring to extract the data. I'm not using regular
> expressions since I know exactly what are the tags to find.
> My function goes like this:
> private string ParseHtml(string html)
> {
> html = html.Replace("\r\n","");
> int begin = html.IndexOf("%%StartGetHtml%%");
> int end = html.IndexOf("%%EndGetHtml%%",begin);
> int begin2, end2;
> string str = null;
> if (begin > 0 && end > 0)
> {
> // Gets the beginning of the tag
> begin2 = html.IndexOf("<",begin);
> // Gets the end of the tag
> end2 = html.IndexOf(">",end-3);
> if (begin2 < end2 && end2 < end)
> {
> // Gets the tag
> str = html.Substring(begin2,end-begin2);
> }
> }
> return str;
> }
> Is this the fastest way or there could be a better way to do this?

If those string processing attempts suffice for you then use them but in
general if you want to parse HTML you might want to check SGMLReader, see
http://www.gotdotnet.com/community/...uery=sgmlreader

--

Martin Honnen
http://JavaScript.FAQTs.com/

Monday, March 26, 2012

The control that triggered the UpdatePanel controls to refresh

Hi All,
On my page, I have a custom control in which asp server controls can be
added and a UpdatePanel to notify the server of any edit in progress in the
custom control...I would like to know which server control triggered the
postback whitin my custom control. Currently, my customControl is declared a
s
follow:
<daf:UpdateInProgressPanel ID="UpdateInProgressPanel1"
runat="server" DisabledStateControlId="Button1"
OnUpdateOccured="UpdateInProgressPanel1_UpdateOccured">
and the following events will trigger a postback:
document.onchange = handleEvent;
interceptor.onclick = handleEvent;
interceptor.onkeypress = handleEvent;
interceptor.onkeydown = handleEvent;
interceptor.onpaste = handleEvent;
My problem is that after postback, I would like to set the focus on the
control which triggered the post back. So far, I have used the following:
string ctrlname = page.Request.Params.Get("__EVENTTARGET");
and
if
(((ScriptManager)this.Page.FindControl("ScriptManager1")).IsInAsyncPostBack)
fromWhere =
this.Page.Request[((ScriptManager)this.Page.FindControl("ScriptManager1")).I
D];
in order to get the control but i am always getting the custom control. I
want to associated postback events to the custom control only but would like
to know which control within it originated the postback...
Any help will be appreciated.
Thanks,
KikaOn Jan 17, 12:09 pm, Kika <K...@dotnet.itags.org.discussions.microsoft.com> wrote:
> Hi All,
> On my page, I have a custom control in which asp server controls can be
> added and a UpdatePanel to notify the server of any edit in progress in th
e
> custom control...I would like to know which server control triggered the
> postback whitin my custom control. Currently, my customControl is declared
as
> follow:
> <daf:UpdateInProgressPanel ID="UpdateInProgressPanel1"
> runat="server" DisabledStateControlId="Button1"
> OnUpdateOccured="UpdateInProgressPanel1_UpdateOccured">
> and the following events will trigger a postback:
> document.onchange = handleEvent;
> interceptor.onclick = handleEvent;
> interceptor.onkeypress = handleEvent;
> interceptor.onkeydown = handleEvent;
> interceptor.onpaste = handleEvent;
> My problem is that after postback, I would like to set the focus on the
> control which triggered the post back. So far, I have used the following:
> string ctrlname = page.Request.Params.Get("__EVENTTARGET");
> and
> if
> (((ScriptManager)this.Page.FindControl("ScriptManager1")).IsInAsyncPostBac
k)
> fromWhere =
> this.Page.Request[((ScriptManager)this.Page.FindControl("ScriptManager1"))
.ID];
> in order to get the control but i am always getting the custom control. I
> want to associated postback events to the custom control only but would li
ke
> to know which control within it originated the postback...
> Any help will be appreciated.
> Thanks,
> Kika
You should open up your custom control as open source so I can take a
gander. I've always wanted a control like what you have created. :)
in client script register a BeginRequestHandler and write the control id to
a
hidden field.
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(
function(sender, args)
{
$get('myHiddenCtl').value = args.get_postBackElement();
});
-- bruce (sqlwork.com)
"Kika" wrote:

> Hi All,
> On my page, I have a custom control in which asp server controls can be
> added and a UpdatePanel to notify the server of any edit in progress in th
e
> custom control...I would like to know which server control triggered the
> postback whitin my custom control. Currently, my customControl is declared
as
> follow:
> <daf:UpdateInProgressPanel ID="UpdateInProgressPanel1"
> runat="server" DisabledStateControlId="Button1"
> OnUpdateOccured="UpdateInProgressPanel1_UpdateOccured">
> and the following events will trigger a postback:
> document.onchange = handleEvent;
> interceptor.onclick = handleEvent;
> interceptor.onkeypress = handleEvent;
> interceptor.onkeydown = handleEvent;
> interceptor.onpaste = handleEvent;
> My problem is that after postback, I would like to set the focus on the
> control which triggered the post back. So far, I have used the following:
> string ctrlname = page.Request.Params.Get("__EVENTTARGET");
> and
> if
> (((ScriptManager)this.Page.FindControl("ScriptManager1")).IsInAsyncPostBac
k)
> fromWhere =
> this.Page.Request[((ScriptManager)this.Page.FindControl("ScriptManager1"))
.ID];
> in order to get the control but i am always getting the custom control. I
> want to associated postback events to the custom control only but would li
ke
> to know which control within it originated the postback...
> Any help will be appreciated.
> Thanks,
> Kika