|
That is why I loved this line which I read somewhere.
'Everyone can program, but not everyone can be a programmer'
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Manas Bhardwaj wrote: I read somewhere.
May be from Here[^]
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Abhijit Jana wrote: May be from Here[^]
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
from where you are looking that name
Cheers!!
Brij
|
|
|
|
|
Brij, He don't know. . If you want to understnd what he actually wants, you need to read all of three post.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
He must provide the links of all connected question to get the answer
Cheers!!
Brij
|
|
|
|
|
ya also we want to check that name is allready exist or not
modified on Saturday, September 5, 2009 5:00 AM
|
|
|
|
|
rummer wrote: i m entering username so we want to check user not enter same username,
so we want to check username by javascript code in clientside.
I didn't get your question . You want to check the same user name already exist or not ?
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Javascript is always at client side and I can not think of any application having two users logged in from one browser.
It would be better if you tell us what you are actaully trying to achieve.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
hii...
i have populated my menu control dynamically.i want the menu items to allign left
but i dont found any such property.also i want to fix the width of menuitems.how can i do it...
reply...thanks..
|
|
|
|
|
Why you not using CSS for fixing such kind of things ?
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
|
In an ASP.NET C# application, I have a class called "MyPanel" derived from Panel. MyPanel contains a Button with a Click event. The click event is handled in the MyPanel class.
When I store any MyPanel objects in the Session variable and retrieve them on a postback, the Click events seem to disappear. When the user clicks a Button inside the MyPanel object, a postback happens, but the click events don't get executed. I have to "relink" the click handlers when I retrieve the MyPanel objects from Session.
I am using InProc Session mode. I had though I could store even complex objects in the Session variable. But I lose the events in the objects.
Is this explainable?
Thanks,
Mark
|
|
|
|
|
Why would you store them in a session ? How do the clicks 'disappear' ? A click event exists only for a postback. Once you store it in the session, it's just an object, it can't fire anything from the session and there's no event to store.
The other issue is that your controls are regenerated on every postback. So, I doubt you'd have a reference to the same control, which means that any clicks that occured, would not occur in the controls you have in your session, as they are not all references to the same control.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
A few questions: Is your mypanel object an actual object on the page, or are you initializing it at run-time? Are you wiring up the events by hand? Where are the events wired (what page event)? Why are you manually storing the object in the session?
If you are re-linking the event handlers with each postback, I imagine that the click event itself is getting lost.
1) click event is generated - postback
2) event is re-linked to a handler (in page load?)
3) original click event should be handled, but the event handler was re-assigned in step 2...event is lost.
I'm guessing that your object is not actually part of the page, but is created at run-time. I'm also guessing that this is why you are losing events. I would try to come up with a solution that involved the mypanel object as a 'static' object on the page. You will also avoid having to put the mypanel object in session state as a result.
Best of luck.
Rob
tagyurit.com
|
|
|
|
|
Thanks for the responses.
To Rob...My MyPanel objects are objects on the page that are being dynamically created at runtime. Therefore at runtime, various user actions cause MyPanel objects to be created. When they are instantiated, the code links up click events for the buttons within.
Since these dynamic MyPanel objects must persist between post-backs, my thought was to store them in an Array-List which is stored in the Session object. It works well, but I find the Click events no longer work after I pull them out of the Session object after the post-back. I must relink the Click events at that time.
I am just wondering why.
Thanks,
Mark
|
|
|
|
|
In a sense, all event handlers are re-linked at postback. The difference is that objects that are static on your page have their handlers automatically linked by the framework. Since your control is dynamic, you must do it yourself.
This link may be of interest to you:http://msdn.microsoft.com/en-us/library/ms178472.aspx[^]
Is it possible to place the panels on the page as static objects and change their visibility property to hide them if you don't need them? Do you have variable set of panels preventing you from doing this? Give me a little more background - maybe there is a simpler solution.
Rob
http://tagyurit.com
|
|
|
|
|
Thanks Rob. I didn't realize that events must be relinked at postback. Since these "MyPanels" are created dynamically, I guess the viewstate doesn't handle that for me and I will have to relink the events myself? That is how I am interpreting what you are saying.
I am still learning about ASP.NET. I will investigate static objects. Maybe that is what I need to use.
Thanks,
Mark
|
|
|
|
|
Hi everyone!
I'm working with a data grid and I would like to tie in some javascript. I have a field with a label that will have a numerical value. Two buttons are also in this cell and I want one to increase that number and the other to decrease it. Is there a way during the grid.databind event that I can add the client side onclick event to the buttons which will in turn be able to find the current row's label control client ID? This way, I can have each button call a single javascript function but pass it the row's label control that I want it to affect. I've done this before with static controls on the page, but I'm not sure how to start this one because (I'm assuming) each label on the gridview will have a different client side ID.
Thanks!
Knowledge is not power, however, the acquisition and appropriate application of knowledge can make you a very powerful individual.
|
|
|
|
|
Its easy...
First write your javascript that might change the value of a textbox, say like this:
<script>
function increaseValue(textId)
{
var elem = document.getElementById(textId);
if(!!elem)
elem.value = parseInt(elem.value) + 1;
}
function decreaseValue(textId)
{
var elem = document.getElementById(textId);
if(!!elem)
elem.value = parseInt(elem.value) - 1;
}
</script>
Now in your GridView.RowDataBound event write :
TextBox tb = e.Item.FindControl("tbValue") as TextBox;
Button btnIncr = e.Item.FindControl("btnIncr") as Button;
btnIncr.Attributes.Add("onclick", "javascript:increaseValue('" + tb.ClientID + "');");
Button btnDecr = e.Item.FindControl("btnDecr") as Button;
btnIncr.Attributes.Add("onclick", "javascript:decreaseValue('" + tb.ClientID + "');");
Now you see when the page is rendered it will hold the buttons with appropriate Onclick Event handlers to process the textbox tb.
Hope you like this solution.
|
|
|
|
|
Oh! slap me in the forehead! I was thinking of the gridview as a whole and how the heck I would find the controls after it's completed. I didn't even think of attacking it at the RowDataBound level. Thanks for the nudge in the right direction!!!
Knowledge is not power, however, the acquisition and appropriate application of knowledge can make you a very powerful individual.
|
|
|
|
|
It happens to all of us..
|
|
|
|
|
Just wanted to update incase anyone else needs to do something similar. I found this site to be helpful as well: GridView and Javascript Also, For some reason the page continued to post back and cause an invalid post back error on the server, but this is resolved by adding the following parameters to the buttons:
buttonPlus.PostBackUrl = "javascript:;";
buttonMinus.PostBackUrl = "javascript:;";
Also, you might need to do e.Row.FindControl if e.Item.FindControl is unavailable.
Thanks!!!
Knowledge is not power, however, the acquisition and appropriate application of knowledge can make you a very powerful individual.
|
|
|
|
|
Yes.. you are right ...
Thanks for update.
cheers.
|
|
|
|
|
Hi Abhishek,
Actually, I believe I spoke too soon! Turns out it fixed the post back problem but broke the rest of my server side asp.Button controls on this page (after I issue the very first javascript command that is). I was playing around with one of my other sites and tried using a server side button that calls a validation javascript function. I got it to call the function but it acted quite similar to this issue in that it would either call the function but still issue the post back to the server each time (without having button.postbackurl="javascript:;"; ) or would call the function but then never actually post back once the validation boolean was set to true (button.postbackurl="javascript:;"; The only way I've found around this so far is to not use an asp.net button control and just create the <input type="button" value="submit" onclick="validateForm();" /> , but that only works with the static pages. I've been googling it for the past day now, but any documentation or references I find give me the impresion that it should just work. Have you ever run into an issue like this? I'm thinking there's a parameter that I'm overlooking, but I can't find it. I've tried setting button.UseSubmitBehavior = true; and / or button.CausesValidation = false; but they just end up causing required validation problems.
Knowledge is not power, however, the acquisition and appropriate application of knowledge can make you a very powerful individual.
|
|
|
|