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

Open new page on button click 1

Status
Not open for further replies.

NerdTop72

Programmer
Mar 14, 2005
117
US
I am having a hard time opening a new page from a button click. I have 2 calendar controls to get 2 dates before i parse a report on another asp page. I display these dates in 2 labels to the user.
when you select the date from the 2 calendar controls and press the button. I set the postbackurl to where i need to go. I have to press it a second time to actually get to that page.

Code:
       Me.btn_Report.PostBackUrl = "~/WSCardDateReport.asp?firstdate=" & Me.lbl_Date1.Text & "&lastdate=" & Me.lbl_Date2.Text

Please tell me a better way? I am looking for something obvious in my intelisense to set but I see nothing that is catching my eye.
Thanks,
Jason
 
if i follow your logic correctly...
the 1st time it's posting to itself. at which point you change the PostbackUrl. When you click the button a second time it is redirecting to WSCardDateReport.asp.
PosbackUrl is just a string property, it doesn't preform any action.
instead of setting the PostbackUrl, just redirect
Code:
string url = string.Format("~/WSCardDateReport.asp?firstdate={0}&lastdate={1}", lbl_Date1.Text, lbl_Date2.Text);
Response.Redirect(url, true);

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks Jason,

How abour changing the target to a new window?

 
that need to happen on client and the button click event won't help.

so remove the button click event.
then assign some js to the OnClientClick property of the button. This is just a string property. so you want something like this
Code:
<asp:Button id="btn" runat="server" Text="View Report" OnClienClick="javascript:OpenReport();" />
<script>
function OpenReport()
{
   var first = get.date.from.page();
   var last = get.date.from.page();
   var url = "WSCardDateReport.asp?firstdate=" + first + "&lastdate=" + last;
   window.open(url, other options here);
}
<script>
for more help with js either google or forum216

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top