hi,
I have a little problem with the function "Page.GetPostBackClientHyperlink".
First some description of my page:
It is a simple testpage for testing "selecting a row af the datagrid by clicking on the whole row". After some googling I thought I found a solution (see code below)
I have a datagrid with 1 Select-column (via the property-building in VS.NET) and some auto-generated colums with data. The "Select-column" is the first column shown in the grid.
I thougt that the code below would do the trick, but the function Page.GetPostBackClientHyperlink(button, "" ) returns javascript:__doPostBack('','')
In the code below I have tested three functions of page.getpostback..., and they return not the correct __doPostback(...) that belongs to the select-linkbutton.
I thought that the button was'n found, but the lines
Dim button As LinkButton = CType(e.Item.Cells(0).Controls(0), LinkButton)
TextBox1.Text &= button.Text
works well and gives me for each row the word "select" witch is the caption/text of the linkbutton.
But the functions to get the wright javascript back doesn't seems to work (and on the internet there the same code without any notion of errors...)
I have fixed the problem (see the commented line of code) by doing some tricks (adding +2 and so..) But I would like to have It worked by the build-in functions, so it will work sure and correct.
Is there someone who can explain why the line
hulp = Page.GetPostBackClientHyperlink(button, "")
give always the wrong javascript ==> return always ==> javascript:__doPostBack('','')
Thank you very much
Frederik
---------------------------------------------------------------
CODE BELOW (code behind, vb.net)
Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles DataGrid1.ItemCreated
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.SelectedItem Then
Dim button As LinkButton = CType(e.Item.Cells(0).Controls(0), LinkButton)
TextBox1.Text &= button.Text
TextBox2.Text &= Page.GetPostBackClientHyperlink(button, "")
TextBox3.Text = Page.GetPostBackEventReference(button)
TextBox3.Text &= Page.GetPostBackClientHyperlink(button, "")
TextBox3.Text &= Page.GetPostBackClientEvent(button, "")
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='beige';this.style.cur sor='hand'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white';")
'e.Item.Attributes.Add("onclick", "javascript:__doPostBack('" & "DataGrid1$_" & "ctl" & Str(e.Item.ItemIndex + 2).Trim & "$_ctl0','')")
Dim hulp As String
hulp = Page.GetPostBackClientHyperlink(button, "")
e.Item.Attributes.Add("onclick", hulp)
End If
End Sub 2 3364
the default link button is rendered as a submit and does not use and javascript. as submit buttons do not have a command name, the value returned is "". you need set command name to the link button for it to work in the manner you want.
-- bruce (sqlwork.com)
"Goethals Frederik" <ivpv_remove_me@remove_me_belgacom.net> wrote in message news:40***********************@news.skynet.be...
hi,
I have a little problem with the function "Page.GetPostBackClientHyperlink".
First some description of my page:
It is a simple testpage for testing "selecting a row af the datagrid by clicking on the whole row". After some googling I thought I found a solution (see code below)
I have a datagrid with 1 Select-column (via the property-building in VS.NET) and some auto-generated colums with data. The "Select-column" is the first column shown in the grid.
I thougt that the code below would do the trick, but the function Page.GetPostBackClientHyperlink(button, "" ) returns javascript:__doPostBack('','')
In the code below I have tested three functions of page.getpostback..., and they return not the correct __doPostback(...) that belongs to the select-linkbutton.
I thought that the button was'n found, but the lines
Dim button As LinkButton = CType(e.Item.Cells(0).Controls(0), LinkButton)
TextBox1.Text &= button.Text
works well and gives me for each row the word "select" witch is the caption/text of the linkbutton.
But the functions to get the wright javascript back doesn't seems to work (and on the internet there the same code without any notion of errors...)
I have fixed the problem (see the commented line of code) by doing some tricks (adding +2 and so..) But I would like to have It worked by the build-in functions, so it will work sure and correct.
Is there someone who can explain why the line
hulp = Page.GetPostBackClientHyperlink(button, "")
give always the wrong javascript ==> return always ==> javascript:__doPostBack('','')
Thank you very much
Frederik
---------------------------------------------------------------
CODE BELOW (code behind, vb.net)
Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles DataGrid1.ItemCreated
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.SelectedItem Then
Dim button As LinkButton = CType(e.Item.Cells(0).Controls(0), LinkButton)
TextBox1.Text &= button.Text
TextBox2.Text &= Page.GetPostBackClientHyperlink(button, "")
TextBox3.Text = Page.GetPostBackEventReference(button)
TextBox3.Text &= Page.GetPostBackClientHyperlink(button, "")
TextBox3.Text &= Page.GetPostBackClientEvent(button, "")
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='beige';this.style.cur sor='hand'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white';")
'e.Item.Attributes.Add("onclick", "javascript:__doPostBack('" & "DataGrid1$_" & "ctl" & Str(e.Item.ItemIndex + 2).Trim & "$_ctl0','')")
Dim hulp As String
hulp = Page.GetPostBackClientHyperlink(button, "")
e.Item.Attributes.Add("onclick", hulp)
End If
End Sub
hmm,
The linkbutton I use is the one that is generated by the datagrid property-builder in VS.net 2003.
I just checked the linkbutton and the command name has been filled in with "Select" Without the quotes.
The datagrid works fine when i just click on the select-linkbutton (the selectcommand is fired (itemcommand en selectedindex_changed...). and the select-linkbutton uses some javascript __dopostback to postback the grid to the server.
I find it very strange because I just followed the instructions from several website and google-groups. They all say that it has to work with the following code
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles DataGrid1.ItemDataBound
Dim itemType As ListItemType = e.Item.ItemType
If ((itemType = ListItemType.Pager) Or _
(itemType = ListItemType.Header) Or _
(itemType = ListItemType.Footer)) Then
Return
Else
Dim button As LinkButton = _
CType(e.Item.Cells(0).Controls(0), LinkButton)
e.Item.Attributes("onclick") = _
Page.GetPostBackClientHyperlink(button, "")
End If
End Sub
but that doesn't work with me. And yes, the default-buit-in-select-linkbutton is in the first colomn of the grid...
Any suggestions
thx
frederik
"bruce barker" <no***********@safeco.com> schreef in bericht news:%2***************@tk2msftngp13.phx.gbl...
the default link button is rendered as a submit and does not use and javascript. as submit buttons do not have a command name, the value returned is "". you need set command name to the link button for it to work in the manner you want.
-- bruce (sqlwork.com)
"Goethals Frederik" <ivpv_remove_me@remove_me_belgacom.net> wrote in message news:40***********************@news.skynet.be...
hi,
I have a little problem with the function "Page.GetPostBackClientHyperlink".
First some description of my page:
It is a simple testpage for testing "selecting a row af the datagrid by clicking on the whole row". After some googling I thought I found a solution (see code below)
I have a datagrid with 1 Select-column (via the property-building in VS.NET) and some auto-generated colums with data. The "Select-column" is the first column shown in the grid.
I thougt that the code below would do the trick, but the function Page.GetPostBackClientHyperlink(button, "" ) returns javascript:__doPostBack('','')
In the code below I have tested three functions of page.getpostback..., and they return not the correct __doPostback(...) that belongs to the select-linkbutton.
I thought that the button was'n found, but the lines
Dim button As LinkButton = CType(e.Item.Cells(0).Controls(0), LinkButton)
TextBox1.Text &= button.Text
works well and gives me for each row the word "select" witch is the caption/text of the linkbutton.
But the functions to get the wright javascript back doesn't seems to work (and on the internet there the same code without any notion of errors...)
I have fixed the problem (see the commented line of code) by doing some tricks (adding +2 and so..) But I would like to have It worked by the build-in functions, so it will work sure and correct.
Is there someone who can explain why the line
hulp = Page.GetPostBackClientHyperlink(button, "")
give always the wrong javascript ==> return always ==> javascript:__doPostBack('','')
Thank you very much
Frederik
---------------------------------------------------------------
CODE BELOW (code behind, vb.net)
Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles DataGrid1.ItemCreated
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.SelectedItem Then
Dim button As LinkButton = CType(e.Item.Cells(0).Controls(0), LinkButton)
TextBox1.Text &= button.Text
TextBox2.Text &= Page.GetPostBackClientHyperlink(button, "")
TextBox3.Text = Page.GetPostBackEventReference(button)
TextBox3.Text &= Page.GetPostBackClientHyperlink(button, "")
TextBox3.Text &= Page.GetPostBackClientEvent(button, "")
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='beige';this.style.cur sor='hand'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white';")
'e.Item.Attributes.Add("onclick", "javascript:__doPostBack('" & "DataGrid1$_" & "ctl" & Str(e.Item.ItemIndex + 2).Trim & "$_ctl0','')")
Dim hulp As String
hulp = Page.GetPostBackClientHyperlink(button, "")
e.Item.Attributes.Add("onclick", hulp)
End If
End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dan R Brown |
last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to
break up this form into several "tabbed" sections, I break up the form using <div>
tags. Each <div...
|
by: brian.newman |
last post by:
I'm trying to use a layer inside a form to hide/reveal a part of the
form, but my code doesn't seem to be working and I need some help
debugging it.
I'm not getting an error which has made it...
|
by: Javier |
last post by:
Hello:
I have a problem with encoding. I get information from a web page, and
sometimes it contains "strange" symbols like "á" and "é", and these come
encoding like "& a a c u t e ;", "& e a c u...
|
by: RJN |
last post by:
Hi
I have a datagrid which is put inside a div tag to make it scrollable. I
need to page the datagrid. The page numbers appear at the bottom of the
datagrid and has to be scrolled down...
|
by: JD |
last post by:
Hello Everyone,
I am writing a asp.net page using vb.net with a datagrid control. I am
trying to detect when a row is clicked on in the grid. And I am not sure how
to do this, if anyone has any...
|
by: Arne |
last post by:
A lot of Firefox users I know, says they have problems with validation
where the ampersand sign has to be written as & to be valid. I don't
have Firefox my self and don't wont to install it only...
|
by: Sue |
last post by:
Web app: asp.net 2003, IE, IIS, VB
top: system.page
-first level: placeholder
--second level: usercontrol
---third level: user control containing a datagrid
Datagrid itemdatabound assigns:...
|
by: John Morgan |
last post by:
I suppose the answer to this is staring me in the face but....
How do I programmatically get a page to post back?
The actual situation is that I am using an aspx table control and
changing the...
|
by: =?Utf-8?B?bGl1eGluZmVpaHU=?= |
last post by:
Hi,
I use post way realization page postback this am must,How realizesunder the
post way controls postback continuously to be unable to findthe solution the
method to hope can obtain master's help...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |