|
Hi,
I've added some code to my RowDataBound event handler to allow the user to select a row in a GridView. Here's the code:
e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';";
e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(this.MyGridView, "Select$" + e.Row.RowIndex);
Nothing special there, it works fine
The trouble is, there's a CheckBox control, a templated one, and I need to set it "read-only" rather than disabled as I don't want it greyed out because it doesn't look great.
I know how to access a templated control and I know how to set a CheckBox control to read-only so I tried the following but it didn't work:
((CheckBox)e.Row.FindControl("MyCheckBox")).Attributes.Add("onclick", "return false;");
I think it's because I've already set the "onclick" attributes for the row but I don't know how to get the control attributes set as well as the row.
Any ideas?
|
|
|
|
|
hey guys i have a image control in my web form. i want to zoom that image when the user clicks the image.
The image is being retrieved from folder . there are two buttons(Next and Previous) to traverse the images and the information about the image name is retrieved from database.
When the first image loads the zooming works fine. but when i click on next or previous the jQuery for the particular images stops working .
According to what i think is the CssClass is being lost for image control. i have tried mentioning
image1.CssClass="magnify" in every function explicitly but does not work
|
|
|
|
|
Do not use URGENT, it is rude. We are here voluntarily to answer questions and what is urgent to you is not to anyone else.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
hi,
This is regarding textbox control, while seeing the page it is showing one value eg: 12/31/1969 but in the view source code of that page shows 12/58/2010.
How can it possible.
|
|
|
|
|
Well, are you looking at the same text control? Are there any other text controls in the page?
The data may be have manipulated by JavaScript code. Is there any JavaScript code that runs on page load?
|
|
|
|
|
Copy "12/31/1969" From your web page. Open the View Soruce, Search >"12/31/1969". Check the result.
|
|
|
|
|
maybe you are updating the value using a client side code (javascript).
Regards,
Jamil
|
|
|
|
|
Hi,
I try to manage the absence of students in the exams, try to insert the id of students absent for each matter,to facilitate that to the user i want insert id_student at once (not one after one by textbox simple)is ther any control or method to do that?
Thanks
|
|
|
|
|
Yes, you can take listbox which shows you student id and name (combination, however in background it will give you ids)
so you can select multiple items from listbox.
On each matter, there is two checkbox (absent and present)
so just select multiple student from listbox
and mark absent or present checkbox and insert it
into database.
Hope this will help!
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Hi!
I do not know if will be easy for the user ,because it is hundreds of students by by matter ,so i must show them all for and check those abcent.
Thanks .
|
|
|
|
|
Hi!
How we can paginate a listbox?
Thanks
|
|
|
|
|
You do not required to do pagination in listbox,
it will automatically shows you scroll bar...
The other best option it you do not want to use
listbox is create your custom control.
Because if you are using grid control then it will
not remember your selection when you select
options from multiple pages....
Hope this will help!
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Thanks Jinal Desai - LIVE,
creating user control seems complicated,I think using multiline textbox:
the user will simply enter ID of abcent students line and in the end I enter that id in the database by a clic buton ,Waht do you Think?
Thank you.
|
|
|
|
|
ya that will be also nice idea.
If you want to just take IDs then it is fine...
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Hi,
That's what I wanted ,it easier for the user but I did not know if there multiline textbox.
I do not know how to check if those id are correct,to prevent the user from making mistakes and insert an id which does not exist in the table student.
Thanks
|
|
|
|
|
Of course there exists multiline textbox in asp.net
You need to use normal textbox and just make it
multiline textbox.
You need to give rows, columns and textmode property according to your
requirement.
Try following....
<asp:TextBox ID="TextBox1" runat="server" Columns="50" Rows="5" TextMode="MultiLine"></asp:TextBox>
Hope this will help!
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
I want to create a class to persist some data which will be accessible no matter what page I navigate to. I am using Server.Transfer(path, true) to switch between pages, and my first thought was to use a static class. But a static class can only contain static members and I need to instantiate new objects on different pages that need to be accessible from subsequent pages. What is the best way to persist this data in a class? Language is C#, .Net framework 3.5.
|
|
|
|
|
It is very simple.
Just create any class in your web application in .cs file or refer any dll (contains your class)
create instance of it.
Store the object in session or application and you can access it from any of your
subsequent .aspx pages.
Hope this will help!
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Naptown Brown wrote: But a static class can only contain static members and I need to instantiate new objects on different pages that need to be accessible from subsequent pages.
you can use static class by using
classname.methodname
for this you have to inherit class at the top of the page.aspx.cs
using namespacename.classname;
hope this may help u.............
|
|
|
|
|
Create a class that inherits "System.UI.Web.Page" and put the properties there that you need to be able to access from all pages. Be sure to build your accessors there as well.
All other pages in your web application should inherit from that class. Then the properties you built there will be accessible...
Something like this:
Public class myPage : Page
{
protected SqlConnection conn;
protected SqlCommand cmd;
public myPage() : base()
{
string connectionString = ConfigurationManager.ConnectionString["DBConnectionString"].ConnectionString;
this.conn = new SqlConnection(connectionString);
this.cmd = new SqlCommand();
this.cmd.Connection = conn;
}
protected int myIntProperty
{
get { return CodeLayer.myProperties.myInt; }
set { CodeLayer.myProperties.myInt = value; }
}
}
Now when you create a new page in your web application, your page should inherit this class. In this example that would mean that whenever the page loads, you would already have an SqlConnection and SqlCommand object defined and usable and you can access your "myInt" property.
public partial class PageOne : myPage
{
protected void Page_Load(object sender, EventArgs e)
{
cmd.CommandText = "SELECT * FROM myTable";
this.myIntProperty = 10;
}
}
- Dave
|
|
|
|
|
Thanks so much for the great example, Dave. I did not consider something like this. It looks like a very workable solution for calling static methods, but my real goal is to persist data in objects between calls to different pages and to do that I cannot use static classes since I have to instantiate data.
I thought about it alot and I think the best approach is to serialize the data in an XML data island between page calls. Then I can pick it up on the next page, de-serialize it, and move on.
Thanks again.
Adam
|
|
|
|
|
You are correct, the data must be stored somewhere. I generally use a database, but any storage method would work.
The idea in my example would be that CodeLayer.myProperties.myInt; would actually do the XML de-serialization in the property's get accessor. It just makes accessing those values very simple when you get to the page level...
- Dave
|
|
|
|
|
Why are you using Server.Transfer? Do you really need all of the viewstate and posted data from one page to be sent to the other? That can be pretty inefficient.
Create a class file in your web project. I would probably put it in its own namespace and then for each page that needs to use the class, add a using statement for that namespace.
What other objects do you need to instantiate and where do those classes live? What kind of persistence are you thinking of? Persisting in memory is usually not a good idea as that doesn't scale very well. You might want to do some research on some design patterns like the domain object model. Then you can look for an ORM (Object relational mapper) that will help you get your objects into and out of a database.
|
|
|
|
|
I put a class file in my project and put it in its own namespace and it is accessible to every page, but I really need access to the data in objects that I instantiate. The data I need must persist for the life of the applicaiton. It is kind of like a wizard app where I am accumulating data page to page for final submission at the end. This is only a 3 month project so I want to keep it simple since the timelines are a bit tight.
I thought about it alot and I think the best approach is to serialize the data in an XML data island between page transfers. Then I can pick it up on the next page, de-serialize it, and move on.
Thanks for your help.
Adam
|
|
|
|