Click here to Skip to main content
15,912,204 members
Please Sign up or sign in to vote.
1.60/5 (2 votes)
See more:
Hi,

I have a data table which have say 200 rows. I want to insert that 200 row values into a table. But i want to execute it in 4 page loads. i.e first 50 are inserted then after that i want to return to the page and then after a pause next 50 and so on. So where i am stuck here is how to implement such function. While returning to the page after inserting the first 50 rows i have to show the status of them as inserted. SO what i am trying to do is to make a call to view page after inserting 50. But how can i achieve it?

I am using c#+html and though not the conventional MVC, but using its concept. so i have to make a call from Model so that page is refreshed.

I have done this
C#
Button btnRefresh = new Button();                
btnRefresh.OnClientClick = "SetMVC('ConfigureMultipleDeviceView','view','DeviceController','frmMVC','0','" + companyId + "','" + companyType + "')";


but how can i make it fire
Posted
Updated 24-Oct-13 22:02pm
v2
Comments
Sergey Alexandrovich Kryukov 25-Oct-13 14:38pm    
First of all, when asking UI questions, you need to tag the UI library/framework or application type you are using. When you write "Button", the question is: "which one"? Full type name, please.
—SA

First, please see my comment to the question.

Firing a button click event, or any other event, is just wrong idea. It is not always possible, because in .NET, by design, an event cannot be invoked from anywhere except declaring class. If a class expose some event-invoking method, then you can do it, but it generally makes no sense. Why to you think .NET events have such a limiting feature (in contrast to "regular" delegate instances). Because at can be dangerous, and, at the same time, not really needed.

If you think at your requirements, you will see that, in fact, you don't want to fire Click. Instead, you want "the same very effect as the user clicked it". Isn't that so? So, do exactly that:
  • Create a separate method implementing what you want to achieve.
  • Call this method from your event handler; do nothing else in that handler.
  • Call the same method from elsewhere, where you wanted to "fire a button click".

  • PROFIT!
  • :-)


Good luck,
—SA
 
Share this answer
 
Your design goal here is not clear:

On the one hand, you imply you want to "automate" the process of inserting 200 "rows" in four steps. By "automate" I mean that the insertion will continue automatically without the user taking any direct action in the UI.

On the other hand, you imply the user should have some control over whether to continue loading after each step is complete.

If your goal is to load in four steps, but to pause and notify the user that each step is finished successfully, that is a scenario where you are essentially giving the user a "status report:" why should the user be able to click a Button ?

But, if you want to give the user some control after each loading step is complete: to continue ? to stop at the current step ? to start over ? Then, that's a scenario where you do want some kind of interface for the user to interact with.

There is a .NET method (WinForms, since FrameWork 1.1) for simulating a Click Event on a Button: [^]. Except for automated testing of a UI in software development, I think using this method is not good software design: why not simply take whatever code is executed inside the Button and make it into a method which the Button calls, and which you can call as needed ?

While you could activate a Timer after each insertion step, and present a Button(s) that allowed the user to cancel, or re-start, etc., for a specific interval, I think that's generally a bad idea.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900