Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I use the RowDataBound declaration on a GridView to navigate away to new .aspx page with Specific window size

Posted on 2012-12-25
9
Medium Priority
?
564 Views
Last Modified: 2012-12-30
i use a following code in rowdatabound event

if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onClick"] = string.Format("window.location = 'CandidateProfile.aspx?candidateID={0}';", DataBinder.Eval(e.Row.DataItem, "candidateID"))

}

i want to change it so the click event opens in a new window with specified height and width

how can i do that , plz help
0
Comment
Question by:panasonic2012
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 38720134
something like:

var url = string.Format('CandidateProfile.aspx?candidateID={0}';", DataBinder.Eval(e.Row.DataItem, "candidateID"));

ClientScript.RegisterStartupScript(this.GetType(), "openWindow",
 "<script>openWindow('url')</script>");

function openWindow(url, redirectUrl) {
    var x = window.open(url, 'mynewwin', '_blank', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=520,modal=yes,alwaysRaised=yes');
    x.focus();
    window.location = redirectUrl;
}

Open in new window


or calling Response.Redirect:

Response.Redirect(string.Format("CandidateProfile.aspx?candidateID={0}';", DataBinder.Eval(e.Row.DataItem, "candidateID")", "_blank", "menubar=0,scrollbars=1,width=780,height=900,top=10");

Open in new window



change the width/height according to your needs.



cheers
0
 

Author Comment

by:panasonic2012
ID: 38720177
is this the server side code ?

do i write the frist code in e.Row.Attributes["onClick"] = .. ?

is the last function openWindow has to be written on aspx ?

plz explain

sorry im new
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38720282
In your aspx add script tag and code the function inside.
So upon row click, the function is being called passing the url with relevant data.
I wasnt infront of a pc but this is the idea.
U can try response.redirect but im not its gonna work, i havent tested it yet
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 42

Expert Comment

by:sedgwick
ID: 38720284
<SCRIPT type="text/javascript"> 
function openWindow(...){

}
</SCRIPT>

Open in new window

0
 

Author Comment

by:panasonic2012
ID: 38720764
these are not working :(
0
 

Author Comment

by:panasonic2012
ID: 38720782
i tried this
e.Row.Attributes.Add("onclick", "javascript:window.open('CandidateProfile.aspx?candidateID=" + DataBinder.Eval(e.Row.DataItem, "candidateID") + "',null,'left=162px, top=134px, width=500px, height=500px, status=no, resizable= yes, scrollbars=yes, toolbar=no, location=no, menubar=no');");

it works but i dont want the click event in the last column of the grid as it has button in that column
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38720788
so u wanna redirect to CandidateProfile.aspx only if user click on specific column?
0
 

Accepted Solution

by:
panasonic2012 earned 0 total points
ID: 38720793
never mind i got it

 if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState == DataControlRowState.Alternate)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                          for (x=0; x < cellCount-1; x++ )
                        e.Row.Cells[x].Attributes.Add("onclick", "javascript:window.open('CandidateProfile.aspx?candidateID=" + DataBinder.Eval(e.Row.DataItem, "candidateID") + "',null,'left=162px, top=134px, width=500px, height=500px, status=no, resizable= yes, scrollbars=yes, toolbar=no, location=no, menubar=no');");
                }
            }
0
 

Author Closing Comment

by:panasonic2012
ID: 38730578
figured it out
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question