How is code behind code processed on client side?
I ask because I'm trying to figure out a problem I have with a link button in a gridview. If I open the page and run it as normal everything fires fine. I click on the link button and it loads the new page. However if I email the page to myself and click on the link button nothing happens. I do not think that the Gridview_Rowcommand fires.
The link button represents a DB ID field and all the code is in the GridView_RowCommand event in the code behind and fires a Server.Transfer at the end to load the new page. I have tried Response.Redirect but it does not matter because the code behind never fires.
Thoughts would be appreciated.
Ty
![]() |
-2 |
![]() |
Code behind and client side code are two completely seperate things. Everything in the code behind executes on the server during postbacks, client side code (i.e. javascript) executes in the browser in between postbacks.
I highly recommend a beginners book to asp.net, as it seems you need a bit of work on the fundamental concepts behind server side scripting in general.
Please remember to Mark As Answered if this post has answered your question
![]() |
0 |
![]() |
TBarton:
However if I email the page to myself and click on the link button nothing happens.
so this implies that the page is also sent to you as email?
code behind are the server-side logic of your web application, hence when you click on the link button from your webpage;
it can process the page's code behind hence executing the logic behind it, which in this case... within your
Gridview_Rowcommand you may have a Respose.Redirect() logic hence linking to another page.
the code-behind's are executed within your web application...
but if what i undertand is that, you also have this page send to you as email; the code behind's logic may no longer be executed since what you would be having may be the HTML page. hence, when you clicked, nothing happened...
you might want to opt to setup a hyperlink column, where you add querystring parameters on it...
i.e.<asp:Gridview id="Gridview 2" style="Z-INDEX: 102; LEFT: 416px; POSITION: absolute; TOP: 56px"
runat="server" AutoGenerateColumns="False">
<Columns>
<asp:HyperLinkColumn Target="_blank" DataNavigateUrlField="[ColumnField]" DataNavigateUrlFormatString="[LinkASPXPage]?id={0}"
DataTextField="[ColumnField]"></asp:HyperLinkColumn>
</Columns>
</asp:Gridview >where:
[ColumnField] = field column, in you case may be the DB ID field as stated...
[LinkASPXPage] = page where the link redirects to...
Clicking “Mark as Answer” would also help other community members reading the thread.
"Two roads diverged in a wood, and I—; I took the one less traveled by, And that has made all the difference. -The Road Not Taken"
![]() |
0 |
![]() |