Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More Chat Room help

Status
Not open for further replies.

swiv

Programmer
Sep 18, 2002
20
GB

When clicking a link we want to open a JavaScript style Popup window and execute a server-side function at the same time.

Have tried LinkButton but can't execute javascript window.open() from Server-Side and have tried hyperlink control but there is no onclick event to execute the required server-side function.

any thoughts?

SWIV
 
What we did for our first chat app was use the window.open to open a "nothing" page
i.e. a page that may be seen breifly, but its purpose is to only execute some code, and then redirect to the true chat page where they can see messages and type them.

That may be a solution for you, depending on what you want to happen on the server side.

D'Arcy
 
If you want a button to do both server and client side script, then something like this will work. Use the link button and in the page_load event add these lines

if not me.ispostback then
button.Attributes.Add("OnClick", "javascript:script here")
end if
That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Mark

Thanks for your help I didn't realise this was possible but It doesn't seem to work properly

i.e.

I have a linkbutton
<asp:LinkButton ID=&quot;Logoff&quot; text=&quot;loggoff&quot; OnClick=&quot;logoff_click&quot; Runat=&quot;server&quot; />

then in the Page_Load your little bit of text that shuts the window...

Logoff.Attributes.Add(&quot;OnClick&quot;,&quot;javascript:top.window.close()&quot;)

it shuts the window but doesn't fire the sub routine...

any ideas
 
Uh..i'm confused:

swiv, you said in your first post that you were trying to do a window.open, not window.close?

btw, the problem your facing is because you're using a link button. Switch it to a regular button, and I gaurantee it'll work. Why? Because link buttons are just <A> tags, and aren't of type Submit (or call the submit on the page).

I remember having a conversation with Link9 (Paul) about this, and we never did figure out why the link button doesn't have the ability to act like its regular button counterpart (from what I remember anyway...the post is still up somewhere...).

D'Arcy
 
Ah, just saw your othr post, so I understand where the window.close came from.

One thing that crossed my mind as well: with CSS (and hte built in properties within vs.net) you can make a regular button look like a hyperlink if you want. That might be the easiest, as that would give you the look you want as well as the functionality.

D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top