I have an ASP page (C# as programming language) A.aspx which has 2 components - Button X and Text Field Y. Whenever a user click button X, it should open up a new dialog B.aspx (say, another IE explorer without the bars/icons) which shows the text in field Y.
I read it on the net...
one solution is to add a script in A.aspx in the onClick property of button X. The problem is I dunno who to propagate the info of field Y to B.aspx. Besides, that wont allow me (or least I dunno) to perform any actions in C# code upon the click of X (since the onClick now runs the script instead of the listerner code in C#)
Another option is invoke B.aspx from the buttonAction_Click code of Button X. However, I have no idea how to do it...and I also have no idea how to retrieve the info from A.aspx when I am in B.aspx
C#/ASP.net - how to open a new browswer window/dialog?performing arts
Okay you're asking two questions here:
First you want to open a new pop up window. To do this you use Javascript code, namely the window.open() method.
Then you want to pass a value from one browser to another. To do this you can use Query Strings.
Sample code:
%26lt;script type="text/javascript" language="javascript"%26gt;
function OpenNewWindow( valueOfY ) {
window.open('B.aspx?Y = '+valueOfY' , 'toolbar=no, scrollbars=no, resizeable=yes, width=550, height=600, left=10, top=50' );
}
%26lt;/script%26gt;
%26lt;asp:Button ID="btnX" runat="server" Text="Open New Window" OnClientClick = "OpenNewWindow( '%26lt;%= txtY.Text %%26gt;' ); " /%26gt;
Hope this helps.
C#/ASP.net - how to open a new browswer window/dialog?binoculars opera theaterplz email me so that I send you the complete code!! You have to enabled emailing so that I people can communicate with you. Regards, Report It
Firstly you have do distinguish between server side code and client side code, knowing that you can only open up a new browser window on the client side, even if it is a pop up window or dialog/model window.
Okay now to open up a dialog window you need to add client side script into you page. The script would be something like this;
%26lt;script language=javascript%26gt;
function Dialog()
{
var sPage;
var sProperties;
sProperties = 'scroll:no';
sProperties = sProperties + ';resizeable:no';
sProperties = sProperties + ';status:no';
sProperties = sProperties + ';dialogWidth:800px';
sProperties = sProperties + ';dialogHeight:750px';
sProperties = sProperties + ';Help:no';
sPage = "B.aspx";
showModalDialog(sPage , window, sProperties);
}
%26lt;/script%26gt;
Now on your onclick event (client side event!) you have to call this function.
eg.
%26lt;input id=X type=button
onclick="javascript:Dialog();"%26gt;
To pass the value of say your textbox Y, you can do this.
%26lt;script language=javascript%26gt;
function Dialog()
{
var sPage;
var sProperties;
sProperties = 'scroll:no';
sProperties = sProperties + ';resizeable:no';
sProperties = sProperties + ';status:no';
sProperties = sProperties + ';dialogWidth:800px';
sProperties = sProperties + ';dialogHeight:750px';
sProperties = sProperties + ';Help:no';
sPage = "B.aspx?Value=" + Y.value;
showModalDialog(sPage , window, sProperties);
}
%26lt;/script%26gt;
and change this ...
%26lt;input id=Y type=text%26gt;
%26lt;input id=X type=button
onclick="javascript:Dialog();"%26gt;
No comments:
Post a Comment