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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LinkButton Question

Status
Not open for further replies.

stevenk140

Programmer
Nov 20, 2003
34
CA
I have a dynamic LinkButton and I wanted to do a number of things with it.

1. Open a new window when it is selected.
2. Pass it parameters not in the query string (since it will have many different params ie. an arraylist...)

How would I do this?

Thanks for any help/suggestions you may have.

Steve
 
To open a new window onclick of a link button:
Code:
private void Page_Load(object sender, System.EventArgs e)
{
 if(myLinkButton.Attributes["onclick"] == null)
 {
  myLinkButton.Attributes.Add("onclick", "javascript:window.open('newWin.aspx')");
 }
}
About passing parameters to a new window but not in the query string: adding to Session will do.
 
Is there a way to do this not using javascript?

For example, on a button click, I need to use items entered into a list box, then pass them off to my next page.

Could I build a query string on button click then open the window?

 
Pass them off to my next page which will replace the existing one, not a pup up?
 
A new browser window will be created.

So I need to create the query string dynamically based on selected items in a list box (hopefully not using javascript).
 
steven: Here's a snippet on how to pass varibles via java and open a page at the same time:

</STRONG><FONT color=&quot;blue&quot;>Sample Date:</FONT>
<asp:textbox id=&quot;txtSampleDate&quot; runat=&quot;server&quot; Width=&quot;70px&quot;/>
<a href=&quot;javascript:GetDate('txtSampleDate','<%=Session(&quot;SDate&quot;)%>')&quot;>
<img src=&quot;./Images/SmallCalendar.gif&quot; border=&quot;0&quot; /></a>

I have a small icon image (gif) which the user &quot;click&quot; on, you can Add this attribute to a button instead - and then a window is opened to the requisit URL and variables from the page passed. Here it is a Session variable.

The corresponding Java function is:

function GetDate(CtrlName, SampleDate){
ChildWindow = window.open('Calendar.aspx?FormName=' + document.forms[0].name + '&CtrlName=' + CtrlName + '&SDate=' + SampleDate, &quot;PopUpCalendar&quot;, &quot;width=270,height=300,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no&quot;);
}

...one method.
 
Adding target=_blank to the <form> tag will probably do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top