.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Stop code execution in JS

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :ASP.Net

I create some JS code programmatically in code behind and I need to stop the code to being executed at a certain point.
In my HTML I have something like that:

<script type="text/javascript">
if(GetBacktoServer()) return;
etc etc etc

In other words I need not to continue to fillMyTable() etc etc if GetBacktoServer() return true. 
I know this could be simply done with:
if(!GetBacktoServer()) {
etc etc etc

but as I'm generating the code programmatically this is quite hard to do for various reasons, so I need to use a return if true. 
The above works fine in Chrome but doesn't work in FireFox and IE. (firebug says return not in function)

Any suggestions?

View Complete Post

More Related Resource Links

stop execution of client-side from server-side.

I have a textbox inside a composite control. I have exposed the textchange event to the page. In the server-side text change event, i need to show an alert box. So i m using ScriptManager.RegisterStartUpScript to raise the alertbox. My problem is the event is fired when any button in the page is clicked and they may execute some client-side script. I need to stop their execution. Anybody knows how to do this? Please help.

The Sanboxed code execution request was refused because the sandboxed code host service was too busy

I am getting following error when I am running my sandbx solution ona virtual machine. "The Sanboxed code execution request was refused because the sandboxed code host service was too busy to handle the request" I verified  in central admin that my  Usercode service is already running. I also tried to run below script using powershell. $acl = Get-Acl HKLM:\System\CurrentControlSet\Control\ComputerName $person = [System.Security.Principal.NTAccount]"Users" $access = [System.Security.AccessControl.RegistryRights]::FullControl $inheritance = [System.Security.AccessControl.InheritanceFlags]"ContainerInherit, ObjectInherit" $propagation = [System.Security.AccessControl.PropagationFlags]::None $type = [System.Security.AccessControl.AccessControlType]::Allow $rule = New-Object System.Security.AccessControl.RegistryAccessRule($person, $access, $inheritance, $propagation, $type) $acl.AddAccessRule($rule) Set-Acl HKLM:\System\CurrentControlSet\Control\ComputerName $acl Any pointer would be highly appreciated!!  

Stop downloading code again and again from TFS

Hi All, I am using TFS (Team foundation Server) for team work. I have source code of around 1 Gb, whenever I format my active drive without deleting the actual source code or remove the workspace I need to download all source code from the server even though I have all souce code intact in my hard drive, which is very painful. Can anyone tell me how I can stop this and continue only the incremental download (means the latest changes only). Or please explain the internal working of TFS server and client. Thanks

Stop code not executing

The code below is executing even if I leave textbox2 Null.  I thought the execution would stop from executing further code.?Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text = "" Then LabelTextBox1.Visible = True Stop End If If TextBox2.Text = "" Then LabelTextBox2Visible = True Stop End If End Sub  

No available sandboxed code execution server could be found

I am deploying the web parts as the sandboxed solution to the sharepoint 2010 environment and getting following error - "No available sandboxed code execution server could be found.", any idea?

Code Execution under System Account



I am trying to run a item event handler. Some of the users will not be having the permissions to execute the code, hence I am trying to run the code under the system account, regardless of the user signed in.

This is the code I have tried:


SPUser user = SPContext.Current.Web.AllUsers[@"SHAREPOINT\SYSTEM"];
SPUserToken superToken = user.UserToken;
 using (SPSite site = new SPSite(SPContext.Current.Web.Url, superToken))



I would like to execute my code block to all the users. Hence I had tried to use the System Account. But when I try to execute the code, I am getting error as "Object reference not set to an instance of an object." when the code is trying to execute the below line:


SPUser user = SPContext.Current.Web.AllUsers[@"SHAREPOINT\SYSTEM"];


How to execute the code using System Account, so that all users have the rights.

Thank you

SQLDumper.exe popup stop the execution of my dtsx.




First, thanks a lots for read this post.

I`ve been problems with my dtsx. Suddenly appear one ms-dos popup(SQLDumper.exe) an this one stops the execution of my dtsx. 

I have Sql server 2008.





The sandboxed code execution error



I have installed SharePoint standard edition on Windows Server 2008. Whenever I try to run a sandboxed solution using Visual Studio, sometimes I get the following message: 

"The sandboxed code execution request was refused because the Sandboxed Code Host Service was too busy to handle the request."

Sometimes it just works and sometimes it does not. I have searched on the internet for this error and the solution was to make sure that the sandbox service is running on central administration web site. Central Administration > System Settings > Maange Services on Server > Microsoft SharePoint Foundation Sandboxed Code Service. In my case this service is always running. So I don't understand why Am I keep getting above error message sometimes?

Thanks, Hitesh

SQL Server 2008 query execution time is different if i execute it in management studio or from code

When I execute query from software which i wrote in c# it required lots of time to complete but if I execute exactly the same query from management studio it will be done in seconds. In both cases execution plan is the same. 

List Item Update Exception from HRESULT: 0x80040E2F Unexpected query execution failure, error code 3


A thread somewhat simliar to this has been posted before as well, but i just wanted to detail out the issue and circumstances

We have a list with 53 columns and 2600 items(and growing. I know its rubbish, but thats the way it is at the moment). The list was created using SharePoint GUI  on a test server, saved as a template with data, and was then imported to the production environment. I can post the list columns and type if it helps.

Every one in a while, on updating an item, SharePoint throws up the very not so helpful error page with "Exception from HRESULT: 0x80040E2F".

We looked into the logs and found that for each suc error, there was a Database level error logged as well.

The error starts with Unexpected query execution failure, error code 3621. Additional error information from SQL Server is included below. "The statement has been terminated." Query text (if available): "BEGIN TRAN;DECLARE... and runs for many lines so i wont post the entire blurb here.

Each time, the item update is successful, despite this error. The list also has an Item Updated event handler attached to it. Every time the update error occurs, the event handler does not seem to be firing.

Anybody can shed light on what is happening. We have tried exporting the list template to another site and everything seemed to work

Stop execute code


I have a command button in a page. WHen user click on it delete record. In the onclick event i have inserted this code:

Dim script As String = "var $dialog = $('<div></div>').html('Record deleted!').dialog({autoOpen: false,modal: true,title: 'Eliminazione..',buttons: {Ok: function() {$(this).dialog('close');}}});$dialog.dialog('open');"

Page.ClientScript.RegisterStartupScript(Me.GetType, "test", script, True)

After this I want to redirect user to another page and I have inserted this code:


But If user click button no confirm window appear.

How I can do it?

Error debugging sandboxed solution: The sandboxed code execution request was refused because the San



I'm trying to deploy a sandboxed solution but I don't succeed.
I created an empty sharepoint project, added a (regular) webpart to it and that's it. Didn't add any code of my own to the project.

Then I hit F5 to deploy it to my sharepoint server (visual studio and sharepoint running on the same machine)

First it gives me an attach security warning, where I hit "attach"
Then a message about scrip debugging disabled where I click ok to enable it.

Then my sharepoint site opens, I log in and it displays my default team site page.
I go edit the page and add my custom web part, and when I click add I get a loading window that seems to hang for a while and then an error:

The sandboxed code execution request was refused because the Sandboxed Code Host Service was too busy to handle the request

I searched google and here on the forums, found several topics describing the same.
I checked and in Central Admin the service "Microsoft SharePoint Foundation Sandboxed Code Service " is started
I also tried to execute the powershell script (even though the server is not running DC)

All to no avail.
Am I missing something here, why do I get this error ?

The sandboxed code execution request was refused because the Sandboxed Code Host Service was too bus


I keep getting this error erratically, i have confirmed that the relevant services are in fact running.

It kinda seems like some component elsewhere might be dragging down the host service, how do i go about troubleshooting this? Is there anyway i can maybe tweak this service to avoid this issue?


This is the error from the log:

FormServer Partial Trust - remote execution for solution 817a7b6d-3f38-46fc-94ef-e1c7f027d754 from site eefa926a-568b-4c36-b39d-0f09a22c323d failed with exception Microsoft.SharePoint.UserCode.SPUserCodeExecutionPipelineFailedException: The sandboxed code execution request was refused because the Sandboxed Code Host Service was too busy to handle the request.    Server stack trace:      at Microsoft.SharePoint.UserCode.SPUserCodeExecutionHost.Execute(Type userCodeWrapperType, Guid siteCollectionId, SPUserToken userToken, String affinity, SPUserCodeExecutionContext executionContext)     at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)     at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)    Exception rethrown

Code Optimized Web Development Profile (VS 2010 and .NET 4.0 Series)

When you first run VS 2010 it prompts you to select an IDE profile to use. The profile you select will configure how tool windows are displayed/docked in the IDE by default and set the default keyboard shortcuts. You can then customize any of these settings by using the Tools->Options menu within the IDE and then override/change them. You can also later reset your profile and pick a different one by choosing the Tools->Import and Export Settings menu command.

Free Code Snippets - ASP.NET

You Can Find Useful ASP.NET Related Posts on the above link.

Free Code Snippets - C#

Free C# Code Snippets

call JavaScript - jQuery code from ASP.NET Server-Side

jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend