|
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.
|
|
|
|
|
yes. .For <asp:button use
btn.Attributes.Add("onclick", "javascript:");
this is the best option to have client side event. Otherwise in the designer you might use
onClientClick="javascript:"
|
|
|
|
|
dang..it is calling the javascript but still issuing the post back to the server and throwing a validation error. I did view the source and I believe the problem lies in the fact that all of the buttons are of type "submit". Is there a way I can programatically change them to type="button" instead? I tried button.Attributes.Add("type", "button") but they are still ending up in the browser as type="submit". Doesn't make any sense. I've seen a ton of forums and articles now indicating that what you've suggested should just work.
[UPDATE] It dawned on me that it was probably because I never changed the UseSubmitBehavior parameter on the button. If I change this to false, then the javascript fires without trying to submit, however it is still posting back and refreshing the page, causing my javascript changes to dissapear during the server's page load. The only way I've found so far to keep the page from refreshing is adding the PostBackURL parameter, but if I do that then all of my buttons on the page seem to "inherit" this and then they won't work. grr!
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lb1 = (Label)e.Row.FindControl("label1");
Button btminus = (Button)e.Row.FindControl("minus_qty");
btminus.UseSubmitBehavior = false;
btminus.Attributes.Add("onclick", "javascript:decreaseQuantity('" + lb1.ClientID + "');");
Button btplus = (Button)e.Row.FindControl("plus_qty");
btplus.UseSubmitBehavior = false;
btplus.Attributes.Add("onclick", "javascript:increaseQuantity('" + lb1.ClientID + "');");
}
Knowledge is not power, however, the acquisition and appropriate application of knowledge can make you a very powerful individual.
|
|
|
|
|
I am trying to write some client-side script from the code behind page using the RegisterStartupScript method of the ClientScriptManager. The script is trying to add an OnChange event handler for an asp:DropDownList control. I am using the ClientID property of the DropDownList in the script. The script is not working. When I tried stepping through the document.all collection to see if the proper ID was being generated, I found that NONE of the elements in the document.all collection had an ID, even though all of the controls on this aspx page have IDs assigned. It appears the IDs assigned in the aspx page are not being passed on to the client's html page. I am using a MasterPage, but this particular control is in the content page, not the MasterPage. What is going on here?
|
|
|
|
|
I think you must use dropdown.ClientID to get that ..
Can you post the code you pass as script in RegisterStartupScript... so that I could clarify where you are wrong...
|
|
|
|
|
Thanks. But since I posted that message, I found the problem. It had to do with some hidden fields on the form. Thanks anyway.
|
|
|
|
|
Great to see you solved yourself.
|
|
|
|
|
Good Day
its Friday and am Tired. i request your assistance here
Am binding a grid with RRS info. now there is a Field that Displays the URL and a i made it to display a Hyperlink in that field like this
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkUserID" runat="server" NavigateUrl='<%# Eval("Link")%>' Text='<%#Eval("Link") %>'>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
Now it appears as a link, Good, but the Problem is that when i click the link it does not navigate to the URL.
Thanks
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
modified on Friday, September 4, 2009 10:23 AM
|
|
|
|
|
Vuyiswa Maseko wrote: when i click the link it does not navigate to the URL
Which URL get opened after you click on link?
Show us how you are saving url in table.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Thank you
this did the Trick
<asp:TemplateField HeaderText ="Link">
<ItemTemplate>
<asp:HyperLink ID="linkurl" runat = "server" NavigateUrl ='<%# Eval("Link")%>' Target ="_blank" Text='<%# Eval("Link")%>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
In RowDataBound of Grid, Use FindControl to identify the GridColumn and use, control.attributes.add() , to add the link.
This will do the job !
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Thank you these did the Trick
<asp:TemplateField HeaderText ="Link">
<ItemTemplate>
<asp:HyperLink ID="linkurl" runat = "server" NavigateUrl ='<%# Eval("Link")%>' Target ="_blank" Text='<%# Eval("Link")%>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
Thanks For your reply
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
You are using server tag for Server Side LinkButton ... this is weird.
Always remember, the server side properties doesnt render to the client, so if you see your browser, the anchor tag will not hold the NavigateUrl Property..
So either you use <a > tag directly here and place href='<%# Eval("Link")%>' ... or use RowDataBound Event of the GridView.
Inside RowDataBound Event use:
LinkButton lnk = e.item.FindControl("lnkUserID") as LinkButton;
lnk.NavigateUrl = DataBinder.Eval(e.item.DataItem, "Link") as string;
Hope you got what you need. ...
Cheers.
|
|
|
|
|
Thank you these did the Trick
<asp:TemplateField HeaderText ="Link">
<ItemTemplate>
<asp:HyperLink ID="linkurl" runat = "server" NavigateUrl ='<%# Eval("Link")%>' Target ="_blank" Text='<%# Eval("Link")%>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
Thanks For your reply
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
use Hyperlink instead
CC26
|
|
|
|
|
Thank you
this did the Trick
<asp:TemplateField HeaderText ="Link">
<ItemTemplate>
<asp:HyperLink ID="linkurl" runat = "server" NavigateUrl ='<%# Eval("Link")%>' Target ="_blank" Text='<%# Eval("Link")%>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
Thanks
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi ...
I need to create a hit counter page of our website by which i can see statistic of our website user as daily basis, monthly and weekly basis..
Thnaks,
Abbas
|
|
|
|
|
Create one table with columns: ID,HintCounter,Date and in every page load of masterpage update value by one in table.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Do you want to track hits or visits because they are 2 very different things?
|
|
|
|
|
What about using Google Analytics[^] ?
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: What about using Google Analytics[^] ?
Well, I love this tool. Lately, I have also started using this. But there are still bits and pieces which are missing in this too.
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.
|
|
|
|
|
Hello,
thanks for providing solution to multiselect dropdown .
I have downloaded the applications and converted it to vs 2005.After conversion the application is running properly but when i copied usercontrol and page
from this application and added to another application i am getting the compilation error mentioned below:
CS0115: 'ASP.webform1_aspx.GetTypeHashCode()': no suitable method found to override
Line 511: Line 512: [System.Diagnostics.DebuggerNonUserCodeAttribute()] Line 513: public override int GetTypeHashCode() { Line 514: return 1203564985; Line 515: }
I am maintaining the same heirarchy and namespace as per original application but unable to resolved it.
Please let me know the solution.
Thanks in Advance!!
|
|
|
|