Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Gridview column LinkButton JavaScript call question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ronc85@gmail.com - 15 Mar 2008 23:59 GMT
I'm using ASP.NET 2.0, C# and AJAX Extensions.

I need help calling a JavaScript function on the Server. I need to
come to the Server to execute a database call and then execute the
JavaScript.

I'm using a GridView column template containing a LinkButton. When the
User clicks the linkbutton the processing is as follows:

1. Make database call to get the URL.
2. If found call a javascript routine to open the URL in a new Window
(The URL is not part of my project).
3. If not found call a javascript to open a popup window.

How do I execute a JavaScript call on the Server? I need to execute a
database call first to get the URL which I then pass to the following
JavaScript routine.

function OpenWindow(sURL, reqWindowName, reqWidth, reqHeight) {

    var leftPosition = (screen.width) ? (screen.width-reqWidth)/2 : 0;
       var topPosition = (screen.height) ? (screen.height-reqHeight)/
2 : 0;

    var sOptions = "toolbar=no, " +
        "location=no, " +
        "directories=no, " +
        "status=yes, " +
        "menubar=no, " +
        "scrollbars=yes, " +
        "resizable=yes, " +
           "top=" + topPosition + ", " +
        "left=" + leftPosition + ", " +
        "width=" + reqWidth + ", " +
        "height=" + reqHeight;

     mywindow=open(sURL, reqWindowName, sOptions)
     mywindow.focus();
}

Thanks,
Sal
Michael Nemtsev [MVP] - 16 Mar 2008 05:07 GMT
Hello ronc85@gmail.com,

why not to make JS call before or after postback?!

calling JS on server doesnt gave u want u want

---
WBR,
Michael  Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour 

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

> I'm using ASP.NET 2.0, C# and AJAX Extensions.
>
[quoted text clipped - 34 lines]
> Thanks,
> Sal
ronc85@gmail.com - 17 Mar 2008 03:07 GMT
Got the answer

       Page.ClientScript.RegisterStartupScript(this.GetType(),
"OpenWindow", @"<script language='javascript'>OpenWindow('http://
www.google.com', '', 800, 800);</script>");

Thanks,
Sal
Mark Rae [MVP] - 17 Mar 2008 03:54 GMT
> <script language='javascript'>

That's deprecated syntax - use this instead: <script type="text/javascript">

Or, even better, get ASP.NET to create the script tags for you so you don't
have to worry about using outdated syntax:

ClientScript.RegisterStartupScript(GetType(), "OpenWindow",
"OpenWindow('http://www.google.com', '', 800, 800);", true);

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

ronc85@gmail.com - 17 Mar 2008 06:01 GMT
Cool. Tested your change and it looks good.

Thanks,
Sal
ronc85@gmail.com - 17 Mar 2008 03:07 GMT
Got the answer

       Page.ClientScript.RegisterStartupScript(this.GetType(),
"OpenWindow", @"<script language='javascript'>OpenWindow('http://
www.google.com', '', 800, 800);</script>");

Thanks,
Sal

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.