Showing posts with label invoke. Show all posts
Showing posts with label invoke. Show all posts

Wednesday, March 28, 2012

Links dont work properly in a working Modal Popup

Is it possible to have client side <a href links inside an extender?

I've got a Modal Popup working. A webservice is invoke via javascript on the client. The webservice queries a database and returns html to the javascript which inserts the markup into the Modal Popup panel. The popup works well, displaying a title, a description and an image. It also displays a <a href link, however this link doesn't work as intended. It displays as a link but when clicked goes nowhere. I've tried it with and without target="_blank". The only way make it function is by right clicking on it and Opening in a new tab or in a new window. Any advice would be very welcome as I'm stuck and it's far from user friendly in it's current state.

Hi oscar,

Do you got some code that replicates the error?

Kind regards,
Wim


Hello,

What is resulting output of the link?

Thanks,

Louis


Thanks both for taking the time to help out. I tried logging in to reply, entered my password incorrectly once and my user account has now been locked out, despite it letting me reset my password.

I've now got this working.

The web service returns a string containing all of the markup to be displayed in the panel:

strdetails += "<a href="http://links.10026.com/?link="""onClick=""javascript:popUp('"
strdetails += ds.Tables(0).Rows(0)("livemaplink").ToString()
strdetails += "')"">Live Map</a>"

then with the rest of the javascript functions in the aspx page is this:

function popUp(URL)

{window.open(URL);}

I'd tried adding the popup function to the panel in the strdetails string and it didn't work but this does.

Thanks again.


Hi oscar Version 2Stick out tongue

Glad you got it to work!

Euhm, Even if none of our answer are actually solutions, I think you can still mark the thread as solved, somewhere on top, or mark your reply as answer. Because this thread is resolved ;)

Kind regards,
Wim


Will do, when my original account is unlocked that is!Big Smile

Cheers.


Will do, when my original account is unlocked that is!Big Smile

Cheers.

Monday, March 26, 2012

listbox ondblclick attribute

Hi

I am trying to invoke a listboxes double click attribute to utilize the Ajax.Net functionality.

I have a listbox in an UpdatePanel, and using the OnSelectedIndexChanged event I successfully perform client side actions using Ajax.
I now want to perform an action when a user double clicks on an item of the listbox. (remove this item)

I tried copying the OnSelectedIndexChanged attribute value generated by dot net and adding it through the code:

lbMyListBox.Attributes.Add("ondblclick","javascript:setTimeout('__doPostBack(\\'DoubleClick\\',\\'\\')', 0)");

This however keeps causing a page post back.
Is it possible to use the double click attribute?
I have searched everywhere without much luck

TIA

You will need to subclass the ListBox control and create the ondblclick event for postback usage... and remove the existing onSelectedIndexChanged event. This topic deals with fairly advanced .Net web control programming.

Here's an example that is quick and dirty... and does not fully take care of all possible scenarios.

public class MyListBox : ListBox, IPostBackEventHandler, IPostBackDataHandler {public event EventHandler OnDoubleClick;#region IPostBackEventHandler Membersvoid IPostBackEventHandler.RaisePostBackEvent(string eventArgument) {if (eventArgument =="ondblclick") {if (OnDoubleClick !=null)this.OnDoubleClick(this, EventArgs.Empty); } }#endregion protected override void OnPreRender(EventArgs e) {base.OnPreRender(e);this.Attributes.Add("ondblclick", Page.ClientScript.GetPostBackEventReference(this,"ondblclick")); }protected override void Render(HtmlTextWriter writer) {//Here we will remove the onchange event through string manipulation. StringWriter sw =new StringWriter(); HtmlTextWriter newWriter =new HtmlTextWriter(sw);base.Render(newWriter); sw.Flush();string html = sw.ToString();int indexofOnChg=html.IndexOf("onchange=\""); sw.Close(); html = html.Remove(indexofOnChg,html.IndexOf(" ", indexofOnChg) - indexofOnChg); writer.Write(html); } }

Thanks for your advice

Will give it a wirl