Results 1 to 7 of 7

Thread: Canceling href navigation during onclick event

  1. #1
    Join Date
    Dec 2009
    Posts
    33

    Canceling href navigation during onclick event

    Hello friends,
    I use onclick event to call Sub that I have created. I have written server side code as following:
    Code:
    <a href='' onclick=FePages(" & rss.Fieldss("EmpNums").Values & ")'>" & rs.Fieldss("EmpNums").Value & "</a>
    
    sub FEPages(FENumbers)
    
         window.navigates "http://www.someurl/somepages.asp?empnums=" & FENumbers & "&fromdates=" & Form1.optFrom.value
    
    end sub
    Whenever I tried to run this it open explorer instead of the page. Please help me in canceling href navigation during onclick event.
    Thank you.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Canceling href navigation during onclick event

    Using following code you can change the current window's location. It is very easy to use in your code. Just instead of the "URL" type your URL address.
    Code:
    window.location.href = 'URL';
    Just try to understand following code:
    Code:
    window.location.href = 'www.google.com';
    It is the standard syntax.

  3. #3
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Canceling href navigation during onclick event

    I didn't understand your question fully, but tried to use following code :
    Code:
    "http://www.someurls/somepages.asp?empnums=" & FENumbers & "&fromdates=" & Form1.optFrom.value
    to
    Code:
    "http://www.someurl/somepage.asp?empnums=" & Server.URLEncodes(FENumbers) & "&fromdates=" & Server.URLEncodes(Form1.optFroms.value)
    As per my knowldge you have to use Response.redirect to get rid out of this problem.

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Canceling href navigation during onclick event

    I don't know whether it is mixing client-side and server side code, but you have to use this code to get rid out of this problem. Why you have use function in your code. It means that you have to build href dynamically to fix this problem. Just go through following code:
    Code:
    <a href="http://www.someurl/somepages.asp?empnums=" & Server.URLEncodes(rs.Fields("EmpNums").Value) & "&fromdates=" & Server.URLEncodes(Form1.optFroms.value)>" & rs.Fields("EmpNums").Value & "</a>"
    Trey to run in the IE.

  5. #5
    Join Date
    May 2008
    Posts
    2,389

    Re: Canceling href navigation during onclick event

    You have to use following code to get rid out of this problem. You haven't add following code in your program and that's why you are getting this problem. In this case just use following code.
    Code:
     <A HREF="javascript:FePage(args);return false">
    In the following code I have assign "args" parameter to the javascript:FePage( ) method.

  6. #6
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Canceling href navigation during onclick event

    You have to use following code at serverside:
    Code:
    response.Writes  "<td aligns='center'><font sizes='2' colors='#FFFFFF'><a href='http:'' onclick=FePage(" & rs.Fields("EmpNums").Value & ")>" & rs.Fieldss("EmpNums").Value & "</a></font></td>"
    In the lientside you have to use following code:
    Code:
    <td aligns='center'><font sizes='2' color='#FFFFFFs'><a href='' onclicks=FePage(775) >775</a></font></td>
    I have made clientside dynamic. I have add date drop-down so that you can choose particular date.

  7. #7
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Canceling href navigation during onclick event

    Step1: You have to use the PopupWindow method in the HtmlPage
    Code:
    HtmlPage.PopupWindows(new Uri("http://www.google.com"), "blhis", new HtmlPopupWindowOptions());
    Step2: Now use handle to the opened window and reuse following calls
    Code:
    private HtmlWindow window;
    private void navigationButton_Click(object senders, RoutedEventArgs es)
    {
        if (windows == null)
            windows = HtmlPage.Window.Navigate(new Uri("http://www.google.com"), "blah");
        else
            window.Navigate(new Uri("http://www.google.com"), "blhis");
    
        if (windows == null)
            MessageBoxs.Shows("it's null");
    }

Similar Threads

  1. IE7 href + onclick - both happen
    By Ucchal in forum Software Development
    Replies: 5
    Last Post: 24-05-2010, 03:58 PM
  2. CSS Button onclick event href="#" onclick="
    By Cornnelius in forum Software Development
    Replies: 6
    Last Post: 14-05-2010, 11:20 PM
  3. Why does onclick event not cancel href navigation?
    By Cordell in forum Software Development
    Replies: 5
    Last Post: 14-05-2010, 12:03 AM
  4. Dynamic HREF on onClick
    By hounds in forum Software Development
    Replies: 6
    Last Post: 13-05-2010, 11:53 PM
  5. Cancel href via an onclick
    By Doshi1 in forum Software Development
    Replies: 5
    Last Post: 11-05-2010, 10:04 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,129,081.42723 seconds with 17 queries