vb.net and javascript

Hello,

I currenty have an area in my gridview where i have a hyperlink
     <asp:HyperLink ID="HyperLink1" onclick="openedit()" style="cursor:hand; cursor:pointer"  runat="server">Edit</asp:HyperLink>

Open in new window


When clicking on the hyperlink it does openedit()
function openedit() {
    window.open("editpostadmin.aspx",
       "mywindow", "menubar=0,resizable=0," +
       "width=350,height=250,toolbars=0");

}

Open in new window


what i want to do is make my link : editpostadmin.aspx contain the gridview row ID.

so editpostadmin.aspx?id=?

i can get the id via e.Row.DataItem("ID") but how do i add it to the javascript page.
runnerjp2005Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bartvdCommented:
You can just type window.open("editpostadmin.aspx?id=1",

with the correct id
0
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
Hi,
in following onclick should be a serverside event not client side
<asp:HyperLink ID="HyperLink1" onclick="openedit()" style="cursor:hand; cursor:pointer"  runat="server">Edit</asp:HyperLink>

so you may use

<asp:HyperLink ID="HyperLink1" style="cursor:hand; cursor:pointer"  runat="server">Edit</asp:HyperLink>

function openedit() {  
    window.open("editpostadmin.aspx",  
       "mywindow", "menubar=0,resizable=0," +  
       "width=350,height=250,toolbars=0");  
   return false;  
}


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        HyperLink1.Attributes.Add("onclick", "return openedit();")
End Sub
0
runnerjp2005Author Commented:
yes but the id changes depending on the post....

0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
if it is in grid view then use follwoing


function openedit(id) {  
    window.open("editpostadmin.aspx?id" +id,  
       "mywindow", "menubar=0,resizable=0," +  
       "width=350,height=250,toolbars=0");  
   return false;  
}


in row databound
        HyperLink1.Attributes.Add("onclick", "return openedit(" + yourIDfiled  +");")
0
runnerjp2005Author Commented:
so editpostadmin.aspx?id= (e.Row.DataItem("ID"))
0
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
function openedit(id) {  
    window.open("editpostadmin.aspx?id=" +id,  
       "mywindow", "menubar=0,resizable=0," +  
       "width=350,height=250,toolbars=0");  
   return false;  
}

HyperLink1.Attributes.Add("onclick", "return openedit(" + e.Row.DataItem("ID") +");")
0
runnerjp2005Author Commented:
I have tried the below and get
Conversion from string "return openedit(" to type 'Double' is not valid.

<asp:HyperLink ID="HyperLink1" onclick="openedit()" style="cursor:hand; cursor:pointer"  runat="server">Edit</asp:HyperLink>

 Dim HyperLink1 As HyperLink = CType(e.Row.FindControl("HyperLink1"), HyperLink)
            Dim thegridid As Integer = e.Row.DataItem("ID")
            HyperLink1.Attributes.Add("onclick", "return openedit(" + thegridid + ");")

Open in new window

0
Imran Javed ZiaConsultant Software Engineer - .NET ArchitectCommented:
if you are getting error on following:
HyperLink1.Attributes.Add("onclick", "return openedit(" + thegridid + ");")

then use as following:
        HyperLink1.Attributes.Add("onclick", "return openedit(" + thegridid.ToString() + ");")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
runnerjp2005Author Commented:
well done!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.