|
Hi,
How to update UI(ASP.NET) on the fly whenever data get changed in back end(SQL Server)? Please Suggest some approach.
Thanks,
Manoj K.
Analyst Programmer
SYNTEL Ltd.
|
|
|
|
|
That's not really possible. The HTTP protocol does not allow the server to send anything to the client without the client asking for it.
You can make the client poll the server for changes, but that of course means that there is a delay as you can't send requests often enough to make the changes appear instantly.
There is a technique called server push that would allow you to send data from the server, but that means that you run a component in the browser that has a constant connection to the server. This of course limits the number of clients that the server can handle.
---
b { font-weight: normal; }
|
|
|
|
|
|
Guffa wrote: That's not really possible.
SqlDependency is ideal for caching scenarios, where your ASP.NET application or middle-tier service needs to keep certain information cached in memory. SqlDependency allows you to receive notifications when the original data in the database changes so that the cache can be refreshed.
only two letters away from being an asset
|
|
|
|
|
Mark Nischalke wrote: Guffa wrote:
That's not really possible.
SqlDependency is ideal for caching scenarios, where your ASP.NET application or middle-tier service needs to keep certain information cached in memory. SqlDependency allows you to receive notifications when the original data in the database changes so that the cache can be refreshed.
Yes, that helps to keep the data in the web application up to date, but still the browser knows nothing about the update.
---
b { font-weight: normal; }
|
|
|
|
|
The best approach would be to use Ajax in order to get the client to Poll the server for changes at regular intervals (once every second say). Ajax lets you update the UI without refreshing and reloading the entire page. Some tutorials on Ajax...
http://www.codeproject.com/Ajax/
Be careful if you do this that you don't overload the server and database with requests.
|
|
|
|
|
|
Look at CacheDependency or SqlDependency if you are using 2.0
only two letters away from being an asset
|
|
|
|
|
i have been assigned a task that is mmm ... any way the problem was solved by creating a web service that uses and "Initiates" a static class which contains a "Queue" for handling FIFO Scenario and a timer that is used to perform some action on the first 4 elements of the queue every specific period .. and i ithink it works fine for now .. but the question is :-
does the life time of this static class -and the queue member of it offcourse - depends on the webservice ?? or what ?? and if not .. what will determine the life time of this static class and its members ??? brifley if this class considered in the memory locations preserved for the use of the web service when will this memory released ??
i'm afraid that this static class and the queue member may be removed form memorey and then loosing this data ..
thanks in advance for your expected cooperation
|
|
|
|
|
Davids_Maguire wrote: i'm afraid that this static class and the queue member may be removed form memorey and then loosing this data ..
Yes, you should be afraid.
The static variable will remain intact as long as the web application is running on the server, but the server may shut down the application any time it feels like it. In that case, the next call to the web service will be starting a new instance of the application, and the static variable will be empty.
---
b { font-weight: normal; }
|
|
|
|
|
thanks so much for help ..
but you said
"The static variable will remain intact as long as the web application is running"
i don't think you mean the web application that calls the WebService
but the static variable will remain in memory as long as the server that hosts web service not the - web application -is running .. right ??
and thanks again
|
|
|
|
|
Right. The web application I was talking about was of course the application where the static variable is. You didn't even mention that it was another web application that was using the web service.
---
b { font-weight: normal; }
|
|
|
|
|
i want create templet coulmn in my datagrid with programing and dynamically.
and i want put a dropdownlist in edititem templet and put a label in item templet in each column. how can do this work
-- modified at 7:01 Sunday 26th November, 2006
|
|
|
|
|
Dear all
i was wondering what regular expression should i use for a 1-6 digits number (0 - 999999)
Thanx in advance
Best Regards
3ala2
|
|
|
|
|
\d{1,6}, I believe.
You should search for and download a program called Expresso for building regex.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
thank u very much
u were very helpful
i found that software and i'll start using it
Best Regards
3ala2
|
|
|
|
|
I am having an application with one text box and one button.
On click on the button it should be clicked state (like switch on / off).
Can any one help on this topic?
kamalnath
|
|
|
|
|
There is no property for the button called state
but u can do teh workaround by declaring a glabal boolean variable "bFlag" and set it to False. Add a text box called txtState
<br />
Dim bFlag As Boolean = False 'False for unclicked and True for clicked<br />
on the button_click event u do the following
<br />
Call checkButton()<br />
<br />
private sub checkButton()<br />
if (bFlag) Then<br />
txtState.Text = "Clicked"<br />
Else<br />
txtState.Text = "Unclicked"<br />
End If<br />
bFlag = Not bFlag<br />
End Sub<br />
u can set the Text property for the textbox as "Unclicked" for teh first time teh page opens
Hope this would help
Best Regards
3ala2
|
|
|
|
|
Unlike Windows XP Home Edition, you can install (enable) IIS on Windows XP Media Center Edition. My question is, is there any (hard-coded) restriction on the number of connections? Another question is, what is the difference between XP Media Center and XP Professional?
Thanks.
|
|
|
|
|
How much expensive openning and closing connection is when connection pool is used ???
Assume I invoke four stored procedures in a page , I open and close the connection for invoking each . How much will it affect the performance of that page ??
calling this in a page :
<br />
Connection.Open();<br />
Connection.Close();<br />
<br />
Connection.Open();<br />
Connection.Close();<br />
<br />
Connection.Open();<br />
Connection.Close();<br />
<br />
Connection.Open();<br />
Connection.Close();<br />
Is it worth replacing it with this. I have made the site like above.It is so hard for me to replace that. What is your suggestion ?
<br />
Connection.Open();<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Connection.Close();<br />
|
|
|
|
|
When Connection Pooling is enabled, connections aren't opened and closed as such, rather a whole bunch are opened all at once and then left open. When you get a connection from the pool you are retrieving a already open connection, and when you close the connection you are simply returning that connection back to the pool but in a left open state. Or so I believe.
Thats means in theory there would be no difference between the two implementations you've shown, however you could always test the performance by measuring the execution speed of the page for the two implementations, and see if there's any difference.
However, good practices dictate that you should only hold onto connection objects for as short a time as possible, as even with connection pooling, retrieving the connection from the pool means that other processes or clients can't use it. So the first practice would probably be the best approach, but if your entire site is done using the second practice, I wouldn't loose sleep over it
Connection pooling is automatic provided you meet the following conditions, the connection string must remain exactly the same (even adding spaces to the string will effect connection pooling, so make sure you have the string stored inside the web.config file, or in some external source, and not hard coded into the class. Also only certain vendors support it I believe, you're using Sql Server with SqlConnection class?
EDIT: Sorry misread your post you implemented the first practice which is good (opening and closing connections as needed for each Stored Procedure). If you're calling all four Stored Procedures immediately one after the other, then you could probably use the second practive of holding onto one connection object.
-- modified at 11:23 Sunday 26th November, 2006
|
|
|
|
|
You said
so make sure you have the string stored inside the web.config file, or in some external source, and not hard coded into the class.
Thank you very much for your help. What is wrong with hard coding the connection string in the class ??? I have defined it in my base business class. Why it affects connection pooling ??
|
|
|
|
|
Easier deployment, if you have to change the connection string for when the web application gets deployed, it's easier to edit an xml file as oppose to edit a class file then recompile it etc.
As for Connection Pooling, as long as you have the connection string defined in one place its fine. If you have the same connection string defined in multiple classes in one class you might write...
"Data Source=localhost;Initial Catalog=databaseName;....."
Whereas in another class you write...
"Data Source=localhost; Initial Catalog=databaseName;....."
Notice the space between localhost; and Initial. Because the strings are different it will clause connection pool to be reset, or use a different pool. Defining the string in one place (such as your business base class) avoids these potential typos.
|
|
|
|
|
Thank you for help. I saw your site ,how do u find execution time of your page ?? sounds intresting . Explain to me please if your like .
|
|
|
|
|
In your code behind file (or wherever you put code)....
private int startTime;<br />
<br />
protected void Page_Init(object sender, EventArgs e)<br />
{<br />
startTime = Environment.TickCount;<br />
}<br />
<br />
protected void Page_PreRender(object sender, EventArgs e)<br />
{<br />
int endTime = Environment.TickCount;<br />
<br />
double executionTimeInSeconds = (double)(endTime - startTime) / 1000.0;<br />
<br />
SomeLabelInYourPageSomewhere.Text = executionTimeInSeconds.ToString();<br />
}
Basically you start the timer early in the page event cycle (the Page_Init) and stop the timer late in the cycle (Page_PreRender) which captures the page execution time for almost everything in between (Page_Onload, Control Initialisation, Data bindind, Events from client side button presses etc.).
|
|
|
|