Hi
I need to pass a variable through a querystring in to another window, popup maybe.
Response.Redirect(
"~/Exam/ExamResult.aspx?sum=" + CalSum);I thought about Target=_Blank but that will only work for links. Would i need javascript for this.
Any know of any solutions
not tricky, yes you do need javascript
in your HREF you put
thetargetpage.aspx?myName=valuePair.
then in the onClick event you use
window.open(this.href,ADDITIONAL WIDTH, HEIGHT, PARAMETERS)
should work pretty easily. the key is the javascript.onclikc takes its own href value which you can string your variables in.
hth,
mcm
You forgot one parameter :-D It's actually
window.open(URL, window name, additional params)
Cheers,
Cheers
But its not a href its a Resonse.Redirect written in C#
If that makes any sense
Code is order:
<
scriptrunat="server">void Button1_Click(object sender,EventArgs e){
int val1 = System.Convert.ToInt32(Q1.SelectedItem.Value);int val2 = System.Convert.ToInt32(Q2.SelectedItem.Value);int val3 = System.Convert.ToInt32(Q3.SelectedItem.Value);int val4 = System.Convert.ToInt32(Q4.SelectedItem.Value);int val5 = System.Convert.ToInt32(Q5.SelectedItem.Value);int val6 = System.Convert.ToInt32(Q6.SelectedItem.Value);int val7 = System.Convert.ToInt32(Q7.SelectedItem.Value);int val8 = System.Convert.ToInt32(Q8.SelectedItem.Value);int val9 = System.Convert.ToInt32(Q9.SelectedItem.Value);int val10 = System.Convert.ToInt32(Q10.SelectedItem.Value);int val11 = System.Convert.ToInt32(Q11.SelectedItem.Value);int val12 = System.Convert.ToInt32(Q12.SelectedItem.Value);int val13 = System.Convert.ToInt32(Q13.SelectedItem.Value);int val14 = System.Convert.ToInt32(Q14.SelectedItem.Value);int val15 = System.Convert.ToInt32(Q15.SelectedItem.Value);int val16 = System.Convert.ToInt32(Q16.SelectedItem.Value);int val17 = System.Convert.ToInt32(Q17.SelectedItem.Value);int val18 = System.Convert.ToInt32(Q18.SelectedItem.Value);int val19 = System.Convert.ToInt32(Q19.SelectedItem.Value);int val20 = System.Convert.ToInt32(Q20.SelectedItem.Value);int val21 = System.Convert.ToInt32(Q21.SelectedItem.Value);int val22 = System.Convert.ToInt32(Q22.SelectedItem.Value);int val23 = System.Convert.ToInt32(Q23.SelectedItem.Value);int val24 = System.Convert.ToInt32(Q24.SelectedItem.Value);int val25 = System.Convert.ToInt32(Q25.SelectedItem.Value);int CalSum = val1 + val2 + val3 + val4 + val5 + val6 + val7 + val8 + val9 + val10 + val11 + val12 + val13 + val14 + val15 + val16 + val17 + val18 + val19 + val20 + val21 + val22 + val23 + val24 + val25;Label1.Text = CalSum.ToString();
Label2.Text = CalSum.ToString();
if (CalSum >= 1) {Response.Redirect(
"~/Exam/ExamResult.aspx?sum=" + CalSum);}
else {
Response.Redirect(
"~/Exam/ExamResult2.aspx");}
}
</
script>As you can see i have button click event and and response.redirect and not a href with an OnClick eventAny ideas
Thanks in advance
Use this:
1if (CalSum >= 1)2 {3string _script ="<script>window.open('Exam/ExamResult.aspx?sum=" + CalSum.ToString() +"','popup','scrollbar=no menubar=no width=200 height=200');</script>";4 ClientScript.RegisterStartupScript(this.GetType(),"pop", _script);5 }6else7 {8string _script1 ="<script>window.open('Exam/ExamResult2.aspx','popup1','');</script>";9 ClientScript.RegisterStartupScript(this.GetType(),"pop1", _script1);10 }
Thanks
Right on, e_screw.
Ruckme, Response.Redirect works on the server, which has no knowledge of the browser (for things like new windows).
Cheers,
Wow theres some serious syntax in there, However it still doesnt work!
I am going to have dump all the script and say where the errors are:
script
runat="server">void Button1_Click(object sender,EventArgs e){
int val1 = System.Convert.ToInt32(Q1.SelectedItem.Value);int val2 = System.Convert.ToInt32(Q2.SelectedItem.Value);int val3 = System.Convert.ToInt32(Q3.SelectedItem.Value);int val4 = System.Convert.ToInt32(Q4.SelectedItem.Value);int val5 = System.Convert.ToInt32(Q5.SelectedItem.Value);int val6 = System.Convert.ToInt32(Q6.SelectedItem.Value);int val7 = System.Convert.ToInt32(Q7.SelectedItem.Value);int val8 = System.Convert.ToInt32(Q8.SelectedItem.Value);int val9 = System.Convert.ToInt32(Q9.SelectedItem.Value);int val10 = System.Convert.ToInt32(Q10.SelectedItem.Value);int val11 = System.Convert.ToInt32(Q11.SelectedItem.Value);int val12 = System.Convert.ToInt32(Q12.SelectedItem.Value);int val13 = System.Convert.ToInt32(Q13.SelectedItem.Value);int val14 = System.Convert.ToInt32(Q14.SelectedItem.Value);int val15 = System.Convert.ToInt32(Q15.SelectedItem.Value);int val16 = System.Convert.ToInt32(Q16.SelectedItem.Value);int val17 = System.Convert.ToInt32(Q17.SelectedItem.Value);int val18 = System.Convert.ToInt32(Q18.SelectedItem.Value);int val19 = System.Convert.ToInt32(Q19.SelectedItem.Value);int val20 = System.Convert.ToInt32(Q20.SelectedItem.Value);int val21 = System.Convert.ToInt32(Q21.SelectedItem.Value);int val22 = System.Convert.ToInt32(Q22.SelectedItem.Value);int val23 = System.Convert.ToInt32(Q23.SelectedItem.Value);int val24 = System.Convert.ToInt32(Q24.SelectedItem.Value);int val25 = System.Convert.ToInt32(Q25.SelectedItem.Value);int CalSum = val1 + val2 + val3 + val4 + val5 + val6 + val7 + val8 + val9 + val10 + val11 + val12 + val13 + val14 + val15 + val16 + val17 + val18 + val19 + val20 + val21 + val22 + val23 + val24 + val25;
Label1.Text = CalSum.ToString();
Label2.Text = CalSum.ToString();
if (CalSum >= 1){
string _script ="<script>window.open('Exam/ExamResult.aspx?sum=" + CalSum.ToString() +"','popup','scrollbar=no menubar=no width=200 height=200');</script>";ClientScript.RegisterStartupScript(this.GetType(), "pop", _script);
}
else
{
string _script1 = "
<script>window.open('Exam/ExamResult2.aspx','popup1','');</script>";ClientScript.RegisterStartupScript(this.GetType(), "pop1", _script1);
}
}
</
script>
Basically it says that there is a:CS1010: Newline in constant
on this line:
string _script ="<script>window.open('Exam/ExamResult.aspx?sum=" + CalSum.ToString() +"','popup','scrollbar=no menubar=no width=200 height=200');</script>";
Cheers i though this would be hard
Thans again
That is because you are writing the code in the aspx page (html) and with that are you trying to write <script> tag inside another <script> tag (your <script runat=server>). The code i provided is in code behind file.
Thanks
I thought it was because there was a newline in the string (after 'no'). However, since you're not using codebehind, you *will* want to change your string slightly as e_screw mentioned to avoid terminating the parent script early:
0');</scr" + "ipt>";
Also, I believe you should have commas instead of spaces between your list of formatting parameters:
string _script ="<script>window.open('Exam/ExamResult.aspx?sum=" + CalSum.ToString() +"','popup','scrollbar=no,menubar=no,width=200, height=200');</scr" + "ipt>";
Awsome it works!!!:):):
Thanks you very much everybody it works
Cheers
0 comments:
Post a Comment