?
Solved

Call Client Script from Code behind ASP.NET

Posted on 2013-01-14
2
Medium Priority
?
645 Views
Last Modified: 2013-01-16
Hello Experts,

I have a Javascript function, which gets called after the button event is processed everything on server. Since, I have lot of validations doing at client side, is it possible I can break the server code once the JS function is called and if no errors continue with the server side execution.Below code get called only after the button event is executed  on server.
 ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "Check('" + Msg+ "');", true);

Open in new window

I need to break the code on server side and execute my Client-Side function and then continue with the remaining server side code.I'm using AJAX Script manager and  button is doing asynchronous postback to the server using update panel.

Thanks,
ASPDEV
0
Comment
Question by:ASPDEV
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 21

Accepted Solution

by:
masterpass earned 1500 total points
ID: 38776855
Just so that I understand you clearly, you want to do the following

user clicks a button

1. client side validation
2. button click in server side
3. go to client side again and perform validation
4. continue server side click event

If this is what you need, then technicaly the answer is no .. since we cannot break a server side operation in between and then return to the same operation

As a best practise, I would suggest that you do the server side validation before processing the event so that there is a very less possibility of errors.

But still if you need to acheive this, you can do something like this


user clicks a button (make sure you have a hidden button in form)

1. client side validation
2. button click event in server side
3. finish the function now and have a startup script so that it submits the form via the hidden button
4. write another server event for the hidden button and continue the event

Happy coding :)

PS: I would never do this approach since it is a not good. I would do a full client and server side valdiation and then process events.
0
 

Author Closing Comment

by:ASPDEV
ID: 38784874
Thanks.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question