Showing posts with label control. Show all posts
Showing posts with label control. Show all posts

Thursday, March 29, 2012

Performance question

I have one question.

DataGrid control is performance cost.Use any other control if possible. That
is by the book.
But I need sorting and paging on all my pages.

So, is there any better solution or I should use dataGrid anyway?

Thank you,
SimonSimon,

Suppose we have 100 thousand records in a datagrid, you
just click next page of data grid and it go get those
100 thousand records again, bind them, and take you
to next page.

what we did we cached datatable in an application object,
and bound it with data grid, and refreshed application object
on every insert/update/delete.

heres some code I used to load datatable for the first time,
or if it is already loaded, use from cache:
If context.Application("dvInvoices") Is Nothing Then
Dim dtTemp As DataTable = daoDgrCache.InvoicesSelectAll '// get
datatable from database
context.Application.Lock()
context.Application("dtInvoices") = dtTemp '// caches invoices datatable
context.Application.UnLock()
End If

datagrid1.DataSource = CType(context.Application("dtInvoices"),
DataTable).Copy.DefaultView

and on invoice record insert/update/delete, I called a proc
to refresh cache by doing this:
Dim dtTemp As DataTable = daoDgrCache.InvoicesSelectAll '// get datatable
from database
context.Application.Lock()
context.Application("dtInvoices") = dtTemp '// caches invoices datatable
context.Application.UnLock()

You can also use per-session caching and file caching.
--
Hope this helps,
Zeeshan Mustafa, MCSD

"simon" <simon.zupan@.stud-moderna.si> wrote in message
news:ez5bylCWEHA.1380@.TK2MSFTNGP12.phx.gbl...
> I have one question.
> DataGrid control is performance cost.Use any other control if possible.
That
> is by the book.
> But I need sorting and paging on all my pages.
> So, is there any better solution or I should use dataGrid anyway?
> Thank you,
> Simon
I don't see any issues using the DataGrid. How many rows are we talking
about in your case. You should also take intto consideration the method
of creating tables in class ASP compared to the performance of compiled
code and also the time taken to implement the features like sorting,
paging, in-line editing etc. The extra money that you can save I feel
that you can invest in your hardware.

Regards,

Trevor Benedict R
MCSD

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
If you came up with your own solution, chances are, it wouldn't have a much
smaller footprint, but the downside would be that it was proprietary, and
therefore, more expensive in the short and long run. I would stick with the
DataGrid.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"simon" <simon.zupan@.stud-moderna.si> wrote in message
news:ez5bylCWEHA.1380@.TK2MSFTNGP12.phx.gbl...
> I have one question.
> DataGrid control is performance cost.Use any other control if possible.
That
> is by the book.
> But I need sorting and paging on all my pages.
> So, is there any better solution or I should use dataGrid anyway?
> Thank you,
> Simon

Performance question

I have one question.
DataGrid control is performance cost.Use any other control if possible. That
is by the book.
But I need sorting and paging on all my pages.
So, is there any better solution or I should use dataGrid anyway?
Thank you,
SimonSimon,
Suppose we have 100 thousand records in a datagrid, you
just click next page of data grid and it go get those
100 thousand records again, bind them, and take you
to next page.
what we did we cached datatable in an application object,
and bound it with data grid, and refreshed application object
on every insert/update/delete.
heres some code I used to load datatable for the first time,
or if it is already loaded, use from cache:
If context.Application("dvInvoices") Is Nothing Then
Dim dtTemp As DataTable = daoDgrCache.InvoicesSelectAll '// get
datatable from database
context.Application.Lock()
context.Application("dtInvoices") = dtTemp '// caches invoices datatable
context.Application.UnLock()
End If
datagrid1.DataSource = CType(context.Application("dtInvoices"),
DataTable).Copy.DefaultView
and on invoice record insert/update/delete, I called a proc
to refresh cache by doing this:
Dim dtTemp As DataTable = daoDgrCache.InvoicesSelectAll '// get datatable
from database
context.Application.Lock()
context.Application("dtInvoices") = dtTemp '// caches invoices datatable
context.Application.UnLock()
You can also use per-session caching and file caching.
--
Hope this helps,
Zeeshan Mustafa, MCSD
"simon" <simon.zupan@.stud-moderna.si> wrote in message
news:ez5bylCWEHA.1380@.TK2MSFTNGP12.phx.gbl...
> I have one question.
> DataGrid control is performance cost.Use any other control if possible.
That
> is by the book.
> But I need sorting and paging on all my pages.
> So, is there any better solution or I should use dataGrid anyway?
> Thank you,
> Simon
>
I don't see any issues using the DataGrid. How many rows are we talking
about in your case. You should also take intto consideration the method
of creating tables in class ASP compared to the performance of compiled
code and also the time taken to implement the features like sorting,
paging, in-line editing etc. The extra money that you can save I feel
that you can invest in your hardware.
Regards,
Trevor Benedict R
MCSD
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
If you came up with your own solution, chances are, it wouldn't have a much
smaller footprint, but the downside would be that it was proprietary, and
therefore, more expensive in the short and long run. I would stick with the
DataGrid.
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"simon" <simon.zupan@.stud-moderna.si> wrote in message
news:ez5bylCWEHA.1380@.TK2MSFTNGP12.phx.gbl...
> I have one question.
> DataGrid control is performance cost.Use any other control if possible.
That
> is by the book.
> But I need sorting and paging on all my pages.
> So, is there any better solution or I should use dataGrid anyway?
> Thank you,
> Simon
>

Performance related Question.....

In my ASP.Net application I am using webcontrols.TextBox to display data. I
can use the Label control to display my data here since I am using this edit
box as read only. Will there be any advantage of using label box instead of
text box in terms of memory usage or any other performance issue ? Please
advice.
CrisHi,

I don't think there are big differences between label and textbox, Both
of them are persistent accross requests.
The only difference is that the label iclude the text within <span> tags
while the textbox in the value property of the <input> tag. So there is
just a sligthly difference in the amount of byte sent to the browser.

Hope this helps

Stefano Mostarda MCP
Rome Italy
Cris Rock wrote:

> In my ASP.Net application I am using webcontrols.TextBox to display data. I
> can use the Label control to display my data here since I am using this edit
> box as read only. Will there be any advantage of using label box instead of
> text box in terms of memory usage or any other performance issue ? Please
> advice.
> Cris
>

Saturday, March 24, 2012

Permission Failures with an embedded windows form. What’s the proper way to do this?

I have a windows web form control that opens up a serial port. When I try to embed it an HTML file, I get a securityException when it opens the port. --System.Security.SecurityException: Request for permission of type System.Security.Permissions.SecurityPermission, mscorlib,.......

1) Is there any way I can just tell the browser to trust this object, or just completely trust anything and everything from a certain web site?

2) Right now I had the DLL download from the server when the page loads. It is quite small so speed isn't an issue, I like the concept of downloading it everytime it is used because it will be easier to keep updated. But in terms of permission I was wondering if the proper way may be to install it as a plug in or addon?

The syntax I currently use is :

<object id="SIOControl1"classid="http:SIOControl.dll#SIOControl.SIOTestControl" height="500" width="500" VIEWASTEXT>

You cant programatically "tell" the browser to just trust it, nor can you tell the browser to trust everything from a specific site, not from your application. Imagine the huge security hole that would be. What you CAN do is as the "user" of said site:

Through Internet Options > Sites > Trusted Sites:

Add the address of your website to the trusted sites section. Then set the security of that "zone" to match what you need to accomplish what you're after.


I don't think the solution is as simple as adding it to a trusted site. Just for testing purposes I did that, and set all IE secuirty options and it still dosn't work.

I've tried to add FullTrust to the site with caspol, but to tell you the truth, I just can seem to figure out the proper command.

I've tried: caspol -addgroup LocalIntranet -urlhttp://localhost/SIOControl/* FullTrust

but it tells me that I have an Invalid Label or name, but when I do a caspol -lg I see LocalIntranet there?

Wednesday, March 21, 2012

Permissions for website on localhost

I have a site "http://localhost/mysite" which has a page containing a window
s
user control which displays a list of all files in a folder on the client
machine.
When I run the webapp I obviously get an error message saying that the .net
framework wont allow permissions to do such a thing.
Can anyone tell me how I can set permissions on my machine so that I can run
this ?Have you defined the permissions in the IIS website properties?
Thats not the problem.
Its the client. I must set up the .net framework to accept any actions
coming from this URL. It must allow my dll to perform whatever it wants on
the client machine.
It just so happens that its on localhost at the moment.
Start here:
http://msdn.microsoft.com/library/d...esssecurity.asp
I have gone in to the .net configuration manager and set the URL as trusted
but still no joy.
To be honest, I'm not sure if this is even possible--at least, without
extensive work.
ASP.NET code executes on the server, and as such, that is all it has
access to.
In addition, JavaScript is restricted from accessing the file system,
so that rules that out.
The only way I could imagine being able to access the client's file
system is to create an ActiveX control that the clients would have to
download and install, and that code would have to be trusted on the
client machine.
You may be better off to re-evaluate the architecture of your
application--does it really need this functionality? If the answer is
yes, you should probably look into developing a windows forms/smart
client.
What exactly are you trying to do, anyway? Why would a user go to your
website to navigate the files on his local machine?

Permissions for website on localhost

I have a site "http://localhost/mysite" which has a page containing a windows
user control which displays a list of all files in a folder on the client
machine.
When I run the webapp I obviously get an error message saying that the .net
framework wont allow permissions to do such a thing.

Can anyone tell me how I can set permissions on my machine so that I can run
this ?Have you defined the permissions in the IIS website properties?
Thats not the problem.

Its the client. I must set up the .net framework to accept any actions
coming from this URL. It must allow my dll to perform whatever it wants on
the client machine.

It just so happens that its on localhost at the moment.
Start here:

http://msdn.microsoft.com/library/d...esssecurity.asp
I have gone in to the .net configuration manager and set the URL as trusted
but still no joy.
To be honest, I'm not sure if this is even possible--at least, without
extensive work.

ASP.NET code executes on the server, and as such, that is all it has
access to.

In addition, JavaScript is restricted from accessing the file system,
so that rules that out.

The only way I could imagine being able to access the client's file
system is to create an ActiveX control that the clients would have to
download and install, and that code would have to be trusted on the
client machine.

You may be better off to re-evaluate the architecture of your
application--does it really need this functionality? If the answer is
yes, you should probably look into developing a windows forms/smart
client.

What exactly are you trying to do, anyway? Why would a user go to your
website to navigate the files on his local machine?

permitting linkbutton no validation but other linkbutton validation required

I have a user control with requiredfieldvalidation on 3 textboxes and a validationsummary .

I have 2 linkbuttons.
1st linkbutton (Get) gets values from a database and puts these values into the 3 textboxes.
2nd linkbutton (set) takes the values from the 3 textboxes and puts these values into the database.

The problem is that when I click the Get linkbutton it brings up validation and says required field is empty.
I need it where validation is only on one button and not the other.

can anyone help

Tim CAdd
CausesValidation=False

to any linkbutton that you don't want to trigger validation.

Steve
thank you but I found a different solution. What I did is something like this.

 require1.Enabled = False

where require1 is a validator

persist Checkbox state in datagrid

hi,

i have a datagrid control in a page with checkbox column and paging option.
i selected some checkbox and going to next page or prev page, if i come back to the same page
the checkbox is not checked in that page.

so how to persist that checked item throughout the datagrid?

can any one help me with codingWhen the page is changed the DataGrid is data bound again therefore repopulating everything from the data source. This means any changes made client-side are lost. Save the changes made to the data source before data binding.

DJ

Friday, March 16, 2012

Persist Page Location

I have an aspx page which has many controls. Just enough to cause the user t
o scroll down a little to see them all. Incidentally the last control is a t
able control which allows you to add a new row dynamically upon clicking a l
ink button.
Because link button fires a postback, which is what is needed in order to ad
d the next row to the table it brings the user back to the top of the page a
fterwards.
I want the user to be back where they clicked on the link button at the bott
om of the page. I recall there is a setting or some easy way to do this but
for the life of me can not remember. Any help would be great!
-DemetriOn 8/4/2004 10:45 AM, Demetri wrote:
> I have an aspx page which has many controls. Just enough to cause the user
to scroll down a little to see them all. Incidentally the last control is a
table control which allows you to add a new row dynamically upon clicking a
link button.
> Because link button fires a postback, which is what is needed in order to
add the next row to the table it brings the user back to the top of the page
afterwards.
> I want the user to be back where they clicked on the link button at the bo
ttom of the page. I recall there is a setting or some easy way to do this bu
t for the life of me can not remember. Any help would be great!
>
SmartNavigation was the way to overcome some of this 'page viewing
state' problems in the browser, but I've heard it's buggy.
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Hi Demetri,
Have a look at Scott Guthrie's TechEd 2003 Black Belt Web Forms presentation
(http://www.scottgu.com) he coveres this scenario, under the title
"scrolling and postback".
Hope this helps,
Michael
This posting is provided "AS IS" with no warranties, and confers no rights.
"Demetri" <Demetri@.discussions.microsoft.com> wrote in message
news:54F55A7E-B548-402A-BCF4-1DBFDD5FF9BE@.microsoft.com...
>I have an aspx page which has many controls. Just enough to cause the user
>to scroll down a little to see them all. Incidentally the last control is a
>table control which allows you to add a new row dynamically upon clicking a
>link button.
> Because link button fires a postback, which is what is needed in order to
> add the next row to the table it brings the user back to the top of the
> page afterwards.
> I want the user to be back where they clicked on the link button at the
> bottom of the page. I recall there is a setting or some easy way to do
> this but for the life of me can not remember. Any help would be great!
> --
> -Demetri

Persist tables controls

Hi everyone,

I don't know why all the controls of the Table class (server control)
has to be reconstructed for each page load. The MSDN said that it is
because the children controls are not the Table properties. But why
other controls like ListBox or DataGrid can persist their child
controls?

I'm very confused about this.

Thanks for any reply,

Nhat YenHi,

all non-controls are persisted via ViewState and they can be restored that
way. But controls do need to recreated on every request (and they then load
their own state indepedently after they have been created)

ListBox works so that it saves the state by calling SaveViewState of its
Items collection (ListItemCollection) which stores the items in key/value
sense. On postback items are loaded from ViewState and ListItemCollection
is reconstructed. E.g ListBox actually uses the similar procedure to
repopulate the collection. ListItems aren't controls so therefore ListBox
can work this way without controls "in the middle".

DataGrid can recreate the controls because they (child controls) are usually
specified in templates (or via columns). DataGrid stores the count of rows
which it uses to recreate the Items collection (by instantiating templates)
and then the child controls load their state independently after they've
been created. So basically DataGrid doesn't store the child controls but
recreates them on postback.

Basically you can't avoid recreating controls because control are themselves
responsible for storing their state. Also it would be terribly inefficient
tho store complete control instances to ViewState, therefore only control
state is stored and controls themselves are recreated.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Nhat Yen" <s2119205@.rmit.edu.vn> wrote in message
news:1d84a655.0402211915.5cfed176@.posting.google.c om...
> Hi everyone,
> I don't know why all the controls of the Table class (server control)
> has to be reconstructed for each page load. The MSDN said that it is
> because the children controls are not the Table properties. But why
> other controls like ListBox or DataGrid can persist their child
> controls?
> I'm very confused about this.
> Thanks for any reply,
> Nhat Yen
Thanks for very clear explanation Teemu, it help me a lot.

Again thank you!

"Teemu Keiski" <joteke@.aspalliance.com> wrote in message news:<erMHQre#DHA.3816@.tk2msftngp13.phx.gbl>...
> Hi,
> all non-controls are persisted via ViewState and they can be restored that
> way. But controls do need to recreated on every request (and they then load
> their own state indepedently after they have been created)
> ListBox works so that it saves the state by calling SaveViewState of its
> Items collection (ListItemCollection) which stores the items in key/value
> sense. On postback items are loaded from ViewState and ListItemCollection
> is reconstructed. E.g ListBox actually uses the similar procedure to
> repopulate the collection. ListItems aren't controls so therefore ListBox
> can work this way without controls "in the middle".
> DataGrid can recreate the controls because they (child controls) are usually
> specified in templates (or via columns). DataGrid stores the count of rows
> which it uses to recreate the Items collection (by instantiating templates)
> and then the child controls load their state independently after they've
> been created. So basically DataGrid doesn't store the child controls but
> recreates them on postback.
> Basically you can't avoid recreating controls because control are themselves
> responsible for storing their state. Also it would be terribly inefficient
> tho store complete control instances to ViewState, therefore only control
> state is stored and controls themselves are recreated.
> --
> Teemu Keiski
> MCP, Microsoft MVP (ASP.NET), AspInsiders member
> ASP.NET Forum Moderator, AspAlliance Columnist
>
> "Nhat Yen" <s2119205@.rmit.edu.vn> wrote in message
> news:1d84a655.0402211915.5cfed176@.posting.google.c om...
> > Hi everyone,
> > I don't know why all the controls of the Table class (server control)
> > has to be reconstructed for each page load. The MSDN said that it is
> > because the children controls are not the Table properties. But why
> > other controls like ListBox or DataGrid can persist their child
> > controls?
> > I'm very confused about this.
> > Thanks for any reply,
> > Nhat Yen
Thanks for very clear explanation Teemu, it help me a lot.

Again thank you!

"Teemu Keiski" <joteke@.aspalliance.com> wrote in message news:<erMHQre#DHA.3816@.tk2msftngp13.phx.gbl>...
> Hi,
> all non-controls are persisted via ViewState and they can be restored that
> way. But controls do need to recreated on every request (and they then load
> their own state indepedently after they have been created)
> ListBox works so that it saves the state by calling SaveViewState of its
> Items collection (ListItemCollection) which stores the items in key/value
> sense. On postback items are loaded from ViewState and ListItemCollection
> is reconstructed. E.g ListBox actually uses the similar procedure to
> repopulate the collection. ListItems aren't controls so therefore ListBox
> can work this way without controls "in the middle".
> DataGrid can recreate the controls because they (child controls) are usually
> specified in templates (or via columns). DataGrid stores the count of rows
> which it uses to recreate the Items collection (by instantiating templates)
> and then the child controls load their state independently after they've
> been created. So basically DataGrid doesn't store the child controls but
> recreates them on postback.
> Basically you can't avoid recreating controls because control are themselves
> responsible for storing their state. Also it would be terribly inefficient
> tho store complete control instances to ViewState, therefore only control
> state is stored and controls themselves are recreated.
> --
> Teemu Keiski
> MCP, Microsoft MVP (ASP.NET), AspInsiders member
> ASP.NET Forum Moderator, AspAlliance Columnist
>
> "Nhat Yen" <s2119205@.rmit.edu.vn> wrote in message
> news:1d84a655.0402211915.5cfed176@.posting.google.c om...
> > Hi everyone,
> > I don't know why all the controls of the Table class (server control)
> > has to be reconstructed for each page load. The MSDN said that it is
> > because the children controls are not the Table properties. But why
> > other controls like ListBox or DataGrid can persist their child
> > controls?
> > I'm very confused about this.
> > Thanks for any reply,
> > Nhat Yen

persistent variables?

I have an ASP page written in VB.NET which needs to work with a persistent collection over a couple of requests.

I have tried using each "control" in a collection, which didnt work, anyways ...

I created a New Collection object, populated it and gave it so a Session() cookie to keep untill the next request/postback, but it only keps the first object in the collection?? :confused:

Does anyone know what I mean or should I write up a basic example showing what I mean?

Any help is appreciated, Thanks :)I think you should try explaining again. You mention persistence of variables, but you talk of controls...
Sure, I'll see if I can hack up a quick example tonight maybe (probably not enoguh time, I dont get home till late).

Maybe this will clarify in the mean time...

I am using a form full of controls, yes, but I am using a session cookie to keep information about these controls between postbacks, and because a single session cookie is keeping information for a fair couple controls it is holding a "collection"

So, a Session Variable is assigned a Collection containing information about the controls on the page.
The controls on your page, do they not persist their values between postbacks? That's the main idea behind ASP.NET.
The Frogs right.
Have you got viewstate enabled for each .net control ?