passing client side variable value to server side

 i have a grid and  by click on the rows, the onrowclick event is fired on client side. I want to pass the row index to the server side.

As there are not sessions variables in javascript so i am stuck to pass the row to the server side.. I have made a texbox and set its value

to the index in the onrowclick event but when refresh calls, the text box became empty as the value set is on client side, i want page to persist

the value,  How can i do that? Tel me some way passing the row index to the server side??

0
M
11/5/2008 7:19:41 AM
asp.net.client-side 24353 articles. 1 followers. Follow

3 Replies
1328 Views

Similar Articles

[PageSpeed] 53

Hi,

You can call GridView_SelectedIndexChanging event on row click event so that you can get the index of the row that is selected

To achieve this you have to add attribute "onclick" to row in GridView_RowDataBound event as

e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.GridView, "Select$" + e.Row.RowIndex);


And in GridView_SelectedIndexChanging you can do whatever you want since you are getting the row index


Thanks & Regards,

Omkar A. Lale

"Courage is what it takes to stand up and speak; courage is also what it takes to sit down and listen."

~ Do Mark as Answer if it solves your query ~
0
Omkar
11/5/2008 9:45:06 AM

Hi i have the exact situation ,did u get the solution?

 instead of grid view am usinh asp:repeater control inside a table

something like following

<table style="font-size:small; font-family:Times New Roman;">

<asp:Repeater ID="rpt" runat="server"

DataSourceID="LinqDataSource1" onitemcommand="rpt_ItemCommand">

<ItemTemplate>

 

<tr>

<td style="display:none;"><%# Eval("PK_ID")%></td>

<td>

<a style="cursor:pointer;color:Maroon;" onclick='javascript:return redirectmenu(<%# Eval("PK_ID")%>);return false;'><%# Eval("MENU_NAME")%></a></td>

</tr>

</ItemTemplate>

 

</asp:Repeater>

<asp:LinqDataSource ID="LinqDataSource1" runat="server"

ContextTypeName="EverRecDataContext" Select="new (PK_ID, MENU_NAME, URL)"

TableName="L_MENU_MASTERs"

Where="FK_PARENT_ID == @FK_PARENT_ID &amp;&amp; IS_ACTIVE == @IS_ACTIVE">

<WhereParameters>

<asp:Parameter DefaultValue="0" Name="FK_PARENT_ID" Type="Int32" />

<asp:Parameter DefaultValue="1" Name="IS_ACTIVE" Type="Int32" />

</WhereParameters>

</asp:LinqDataSource>

</table>

0
Monalisa
11/5/2008 11:14:15 AM

Hi 

You can write code under the "gridView_SelectedIndexChanged" and you will be able to get the selected row number.

Hope this will solve the issue.

John

0
mejohn
11/5/2008 12:42:59 PM
Reply:

Similar Artilces:

Client side code to pass values to server side variable?
Hi there, I have ListBox_SelectedTextChanged() method that creates another list box in the runtime as follows: // Get Action Level List lbxActionLevel = new ListBox();lbxActionLevel.ID = "ddlA" + i.ToString(); lbxActionLevel.Width = 100; lbxActionLevel.Rows = 2;SqlDataReader dr = new BusinessLogicLayer().bllGetActionLevels(); lbxActionLevel.Items.Clear();while (dr.Read()) {ListItem lAction = new ListItem(); lAction.Text = dr.GetString(1).Trim();lAction.Value = Convert.ToString(dr.GetInt32(0)); lbxActionLevel.Items.Add(lAction); lbxActionLevel.SelectedIndex = 0; } I ...

Passing variable between client side and server side
For example,how do I pass the return value of the confirm("whatever") to the server side? Or the opposite way.  I want to use a cookie to do is. Can some one give me hint.  Much appreciate your help.   Chen  Please "Mark as an Answer" if you think my post had helped you!Thanks. you can use ajax,javascript and cookies also.  Got what you needed. Please mark as answer. In the aspx file: <input type="hidden" id="confirmAnswer" name="confirmAnswer" runat="server"> That adds this to the...

How to pass values from client side to server side
Hi, Is there a way to transfer variable from a client loop to a server loop. For example: var clitest = 'test'; Now I would like to get test variable from javascript into a server string variable <% sertest = ?? %> I understand that this can be done by storing a variable into a hidden control for example and than access it using server side, but when I have to transfer an array for example it get's a little more complicated. I was wondering is there more efficient approach? You can't transfer arrays, only strings. To workaround this problem pass delimited stri...

How to pass the client side values to server side?
 hello to All,Actually i wanna implement a code like... a string in HTML textbox retrieve in server side control....suppose i hv a HTML control <input type="text" id="txtHTML"/>, and dis control  txtHTML.text="abc".now i want to retrieve dis client side string "abc" in d server side textbox named "txtASP"...which hs a property runat="server"so please give me an idea how to pass values from client side to server side.... hope u understand a problem... sam.  You could do this <input type="text"...

Problem passing value client-side to server-side
I have a page that calls a pop-up while passing an encrypted value via a query string. The value is encrypted on the parent client-side in javascript so it needs to be decrypted client-side as well. This decryption occurs on closing the child (popup) and I am at a loss of when and how I should get this value to the server-side. On the popup you just want to process server side code? Anytime you can access for example the raw url:string raw = Page.Request.RawUrl;If you need to access any values on the client side you can access the url using javascript. Another idea is to, on the code beh...

how to pass values from client side to server side #2
Hi Guys....               This is Aani....I'm using ASP.NET in C# language.i have created one webpage for get input from user(from java script inputbox).i want that entered data in server side operations.how can i pass that value from client side server side.i need proper code in C# language.reply me soon... Thanks is Advanced... Regards....Aani plz use hidden field.ur assing values to text boxes through java script. before post back call a java scipt function to assign value to hodden fieed. even u can add these ...

How to pass a server side string variable to client side
Hi, In my application I want to send(or pass) a server side string variable to the client so that the client side javascript can operate on that string. I am new to ASP.NET. Can anyone please help me with some code snippets? If you allow a postback for this passing, you could store the string in a HiddenField and use javascript to read its value after a post~ If you want it to be more smooth and you are using asp.net 2.0, Script Callback is a good choice, there is a sample at the buttom of this page. Furthermore, some ajax framework will help you to call page method from client esa...

Getting hidden variable value from server side in client side
hi,        I am struck in problem. I have a hidden field in my form and i am setting some value in that.         Now i wnt to use this value from client side but i m not able to retrieve it. All i am getting there is an object.         I feel the hidden field is not able to hold that value.         <input type="hidden" id="hdnVar" runat="server" />         in code behind      ...

Passing a value from server side to client side without postback
My problem exactly is that on my aspx.vb code-behind, I can update the field using HiddenField ID = "hidSessionTimeout" Code-Behind: on Page_LoadhidSessionTimeout.Value = HttpContext.Current.Session.Timeout on ChangeTimeOutValue()hidSessionTimeout.Value = 5  Client-Side: var x= document.getElementById("hidSessionTimeout"); It seems that the javascript cannot get the latest updated value... Any ideas?    Any Workaround solution? did u keep the page load code in if(!IsPostBack)pavankumar geljian_a:  Client-Side:  var...

How to pass param values from server side to client side scripts
Hi, I have a page containing a datagrid with a list of geographic positions of interesting places. Users can filter this grid. Clicking an item the system displays the place on a map using MS Virtual Earth map component that exposes a client side javascript api. My problem is that the filtering is done on server side, but the map runs on client side. So during page load, I need to create long strings containing complex javascript codes on the server side, and add it as an event handler attribute to my components. This causes a lot of problems, for exemple...

Client-side values to server-side ?
Hi! My previous query is attached below: I have implemented the below mentioned implementation . 'listbox1' on 'webform1' shows all the values from 'webform2'. I have implemented it using javascript. I would like to know that to implement validation on 'webform1', I would require the values of 'listbox1' ,which are on the client-side , to move to the server-side . I think sending a querystring will be fine but how to implement it using javascript and code-behind(C#)? Your suggestion will be appreciated. Thanks and regards, ap.       My previous query: " I am stuck wi...

Client Side values to Server Side
What is the best way to transfer Client Side values to the Server side? For example I have a variable "var1" in javascript. var1 = "sample"; How can I acquire this value in the server side?  What is the best approach for this?  Barry to send the value to the server during a postback, you need to place the value in an input control.  You could consider using a hidden textbox for that purpose.Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/ In the JavaScrip...

server side control passing value of self in client side function
I have a server side dropdownlist control.It contains values as:"#00FFFF""#FF00FF""#FFFF00"When the selectedindex is changed by the client I want to assign the value of the dropdownlist to a <div id="example"></div> evelement.pseudo:document.getElementbyId('example').bgcolor=dropdownlist.valueHow can I do this? I think I somehow need to attach a function to my dropdownlist which passes its own value as a parameter to a function...any suggestions?Thanks!please mark answers as 'Answered' and post back solutions when you figure stuff out that isnt in the post already. You ...

How do I pass client side values to server side ones & vice versa
Hi, If I have some jscript that creates a value based on a users input, how can I pass that to a server variable? Many thanks@nt Hi! You can set that value to a hiddenfield (runat = server) on the client and then read it from server side like any other control. If this is not clear, please paste your code so I may help you better.Regards,ClaudioSimplicity: "the art of maximizing the amount of work not done." Thanks for your time crfenix,  I need to do something like below: Code behind:protected void Page_Load(object sender, EventArgs e) {strin...

Web resources about - passing client side variable value to server side - asp.net.client-side

Variable - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Westpac interest rate rise is one of many variable loan rate rises
WESTPAC is not alone in hitting its owner-occupier customers with a surprise interest rate rise, as dozens of other variable rate home loans ...

Airbnb upgrades variable pricing tool for hosts
Online home rental group Airbnb is rolling out an upgraded variable pricing tool that automatically raises or cuts room rates based on supply ...

Commonwealth Bank raises variable home loan rates
Home owners' mortgage costs are set to rise by hundreds of dollars a year, after the Commonwealth Bank became the latest bank to hike interest ...

CBA lifts variable home loan rates to offset costs associated with stricter capital requirements
The Commonwealth Bank to lift its home loan interest rates independently of the Reserve Bank to partially offset costs associated with stricter ...

Washington Square Signs Spielbergs, Choi Joins Variable and More
... films and an episode of the HBO comedy series "Girls," on which he plays the role of Ray Ploshansky. New York-based creative collective Variable ...

YouTube v10.32 Tweaks Some Interface Elements And Includes Hints About Virtual Reality Content And Variable ...
Forget Update Wednesday! Monday is the new big day. Not only were we treated to the latest M preview release and the official Marshmallow name, ...

"You have to ignore many variables to think women are paid less than men. California is happy to try." ...
Writes Sarah Ketterer in The Wall Street Journal in "The ‘Wage Gap’ Myth That Won’t Die" (which you can get to without subscribing if you Google ...

Cisco Debuts Open Pay Variable Pricing, Updates CCRE
Cisco Debuts Open Pay Variable Pricing, Updates CCRE Channel Partners Kris Snow, president of Cisco Capital, says the company's new Open Pay ...

Expert Reveals the Latest Variable Capacity Technology
Learn about gForce Ultra CRAC equipment, the latest variable capacity technology to lower energy usage and increase reliability.

Resources last updated: 12/12/2015 12:53:08 PM