I have a webservice and a default.aspx page in c#.
I want to perform a click of the link button on default page from the webservice.
How can i call the linkbutton of the default.aspx from the webservice?
Please suggest a genuine way for doing this.
Web services cannot "click" buttons. They can return data or perform certain process on their end; you in turn can hook into any callback function after the web service finishes processing to perform the click on your end.
Example:
$.ajax({
url: "URLTOWEBService.here",
success: function(){
//webservice returned successfully
performClick();
}
});
What does the button do? Instead of trying to click it remotely you should change architecture of your system to invoke logic under button via web service.
the closest you can get is if you return a javascript that "clicks" the button and is evaluated by the browser client.
The webservice itself can't do jack since its running on the server.
Related
In my C# code behind file I want to init a window on the client?
Ie. Window.open();
This should be fed with DialogTitle and DialogText and sent to the client.
I can set the window in the HTML and hide it until .open(); is called?
Is this task even possible Server side?
You can't call anything on the client from the server. However, you can send code to do so, for example JavaScript code or just plain HTML. If you are using ASP.NET Web Forms, the Page.RegisterClientScriptBlock method can be useful.
When you render the page, or a AJAX callback, put some <script> element in there with the code to open the window. Then you are all set. If it is an AJAX call, you have to execute the script, which is a little harder than just rendering the script element. See here how to do that.
I need to simulate a button click on my ascx page. The user firstly clicks on a button on the service home page which links to a certain service and a new window opens for that related service. If they are not logged in it directs them to the login page. A querystring is sent with it to keep note of what service they had originally clicked. When the user then logs in they are redirected back to the services page and the querystring of what they clicked on before is sent also.
I have up to this point working fine. The problem is that when I'm redirected back to the online services page I need to simulate an onclick event which will open the new window. I cant click on an the onclick method for the button as there is none, everything is done dynamically. Any ideas?
I would have thought the easiest way to achieve what it sounds like you're trying to do is in the code behind for your Online Services Page check to see whether the query string contains the url for the service they clicked on before you sent them to the login page, if it does then add some javascript to run on start up which launches the pop-up (using the ClientScriptManager.RegisterStartupScript method: http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerstartupscript.aspx).
If you absolutely have to fire the click event you can also do that from your javascript by finding the button you want to click by it's ClientId (using getElementById) and then calling the javascript click() method on it. Here is an example: http://www.w3schools.com/jsref/met_html_click.asp
when user close the web site that time i need to call some function here, what was the event for user close the page or browser in asp.net(C#).
You cannot do this with asp.net. The server does not know when the user closes the window. However you can use javascript, and attach an beforeunload event to the body tag.
window.onbeforeunload = function (e) {
//javascript code here
}
Here is a good SO thread on how this can be achieved.
There is no event in asp.net that could catch the event of user closing the window, because that happens on client-side. Your C# code runs on the server without any knowledge of the client's software.
There are some mechanisms using javascript and sending some data using ajax, but no one should rely on that.
I want to get the [browser] close button event in my web app.
I know how to get it client side by javascript but there are some problems within.
Is it possible to get this event server side in my web app?
Thanks
Can't be done through server code, but you can add some code on your server-side event which adds <script type="text\javascript">window.close();</script> when it finishes.
Have a look at ClientScriptManager.RegisterClientScriptBlock.
I have a C# app that uses a web browser control to display some HTML and do some JScript in the background.
How do I integrate this with other system calls? Do I call other C# code from JScript/VBScript? Do I need to do it from the form itself?
When I need javascript hosted in a webbrowser control to call back to the parent, I have it try to navigate the page to another URL. Then in the webbrowser's "BeforeNavigate" event, I get the URL the page was trying to go to, parse out any arguments, dispatch the request to the other C# code, then cancel the original navigate request.