|
Hi all.
I have a C# ASP.NET project. I have a user control which utilises ajax for its functionality.
The usercontrol has 3 links that should display something above it when clicked. This part does not work on my PC. The EXACT same project that runs on my team mate's PC works fine. The usercontrols link events fire and display properly on his side.
Is there some sort of setting/option I am missing somewhere?
I have the !DOCTYPE declaration on my container form.
Please assist.
Thanks
M
|
|
|
|
|
The browser and browser setting from your machine and your team mate's PC are the same??
Show us the code that doesn't work in your machine and what error you are getting?
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Yes the setting are the same.
There is no error, the link that should display things, is not working at all.
I have 3 hyperlinks alongside each other, the link that is clicked should change colour so that it's different to the other 2 and display text within the user control.
I doubt there is anything wrong with the code, as it works on our test server and my team mate's PC, except on mine. I ran a sample ajax project that i downloaded, and that works on my PC.
It does not work in firefox as well. What else am i missing?
This is the usercontrol's .cs file:
using System;<br />
using System.Data;<br />
using System.Configuration;<br />
using System.Collections;<br />
using System.Web;<br />
using System.Web.Security;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
using System.Web.UI.WebControls.WebParts;<br />
using System.Web.UI.HtmlControls;<br />
<br />
public partial class UserControl_tabcontrol : System.Web.UI.UserControl<br />
{<br />
#region " Variables "<br />
protected string color1 = string.Empty;<br />
protected string color2 = string.Empty;<br />
protected string color3 = string.Empty;<br />
#endregion<br />
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
}<br />
<br />
#region " Section used to display selected content "<br />
protected void lbContent_Click(object sender, EventArgs e)<br />
{<br />
lblMessage.Text = ConfigurationManager.AppSettings["TabControlMessage"];<br />
litDisplayCategory1.Text = string.Empty;<br />
LinkButton lb = sender as LinkButton;<br />
switch (lb.CommandArgument as string)<br />
{<br />
case "1":<br />
litDisplayCategory1.Text = GDDataAccess.DisplayTabArticle(ConfigurationManager.AppSettings["Content1"]).ToString();<br />
color1 = ConfigurationManager.AppSettings["ColorTabControlSelected_#cc99ff"];<br />
color2 = ConfigurationManager.AppSettings["ColorTabControlNotSelected_#9400a3"];<br />
color3 = ConfigurationManager.AppSettings["ColorTabControlNotSelected_#9400a3"];<br />
break;<br />
case "2":<br />
litDisplayCategory1.Text = GDDataAccess.DisplayTabArticle(ConfigurationManager.AppSettings["Content2"]).ToString();<br />
color1 = ConfigurationManager.AppSettings["ColorTabControlNotSelected_#9400a3"];<br />
color2 = ConfigurationManager.AppSettings["ColorTabControlSelected_#cc99ff"];<br />
color3 = ConfigurationManager.AppSettings["ColorTabControlNotSelected_#9400a3"];<br />
break;<br />
case "3":<br />
litDisplayCategory1.Text = GDDataAccess.DisplayTabArticle(ConfigurationManager.AppSettings["Content3"]).ToString();<br />
color1 = ConfigurationManager.AppSettings["ColorTabControlNotSelected_#9400a3"];<br />
color2 = ConfigurationManager.AppSettings["ColorTabControlNotSelected_#9400a3"];<br />
color3 = ConfigurationManager.AppSettings["ColorTabControlSelected_#cc99ff"];<br />
break;<br />
default:<br />
break;<br />
}<br />
}<br />
#endregion<br />
<br />
#region " Public properties "<br />
public void LoadContent(string arg1,string arg2)<br />
{<br />
lbContent_Click(lbContent1, new System.Web.UI.WebControls.CommandEventArgs(arg1, arg2));<br />
}<br />
<br />
public void ShowHideTabControl(bool bValue)<br />
{<br />
if (bValue)<br />
pnlTabControl.Visible = true;<br />
}<br />
#endregion<br />
}
And this is the usercontrol's designer source:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile = "~/UserControl/tabcontrol.ascx.cs" Inherits = "UserControl_tabcontrol" %><br />
<br />
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"<br />
Namespace="System.Web.UI" TagPrefix="asp" %><br />
<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<asp:UpdatePanel ID="ajaxDisplayContent" runat="server"><br />
<ContentTemplate><br />
<asp:Panel ID="pnlTabControl" runat="server" Visible="false"><br />
<table border="0" cellpadding="0" cellspacing="0" width="458px" style="height:160px"><br />
<tr><br />
<td colspan="2" style="font-weight: bold;text-transform: uppercase;text-indent:10px;height:30px;text-align:left;background-color:#669966;font-size:8pt"><br />
<asp:Label ID="lblMessage" runat="server" ForeColor="white"></asp:Label><br />
</td><br />
</tr><br />
<tr><br />
<td><br />
<table border="0" cellpadding="0" cellspacing="0" width="100%"><br />
<tr><br />
<td colspan="3" style="background-color:#bbbbbb;color:White;text-align:left;"><br />
<table border="0" cellpadding="5" cellspacing="5" width="100%" style="width:230px;height:130px;"><br />
<tr><br />
<td style="background-color:#bbbbbb;"><br />
<asp:Literal ID="litDisplayCategory1" runat="server"></asp:Literal> <br />
</td><br />
</tr><br />
</table> <br />
</td><br />
</tr><br />
</table> <br />
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="height:30px;"> <br />
<tr><br />
<td style="text-align:center;background-color: <%= color1%>;"><br />
<asp:LinkButton ID="lbContent1" style="text-decoration:none;" runat="server" CommandName="Content1" CommandArgument="1" OnClientClick="" OnClick="lbContent_Click"><div style="FONT-SIZE: 12pt; color: #ffffff;font-weight: bold;"> 1 </div></asp:LinkButton><br />
</td><br />
<td style="text-align:center;background-color: <%= color2%>;"><br />
<asp:LinkButton ID="lbContent2" style="text-decoration:none;" runat="server" CommandName="Content2" CommandArgument="2" OnClientClick="" OnClick="lbContent_Click"><div style="FONT-SIZE: 12pt; color: #ffffff;font-weight: bold;"> 2 </div></asp:LinkButton><br />
</td><br />
<td style="text-align:center;background-color: <%= color3%>;"><br />
<asp:LinkButton ID="lbContent3" style="text-decoration:none;" runat="server" CommandName="Content3" CommandArgument="3" OnClientClick="" OnClick="lbContent_Click"><div style="FONT-SIZE: 12pt; color: #ffffff;font-weight: bold;"> 3 </div></asp:LinkButton><br />
</td><br />
</tr><br />
</table> </td><br />
<td><br />
<table border="0" cellpadding="0" cellspacing="0" width="100%"><br />
<tr><br />
<td style="width:230px;height:130px;"><br />
<img src="../images/FreeNews.jpg" alt="" id="imgTabControl"/> <br />
</td><br />
</tr><br />
</table><br />
</td><br />
</tr><br />
<tr><br />
<td colspan="2"><br />
<div style="FONT-SIZE: 6px; color: #ffffff;"> </div><br />
</td><br />
</tr><br />
</table><br />
</asp:Panel><br />
</ContentTemplate> <br />
</asp:UpdatePanel>
|
|
|
|
|
Sorry the usercontrol's source was not complete:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile = "~/UserControl/tabcontrol.ascx.cs" Inherits = "UserControl_tabcontrol" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<asp:updatepanel id="ajaxDisplayContent" runat="server">
<contenttemplate>
<asp:panel id="pnlTabControl" runat="server" visible="false">
<asp:label id="lblMessage" runat="server" forecolor="white">
|
<asp:literal id="litDisplayCategory1" runat="server">
|
|
<asp:linkbutton id="lbContent1" style="text-decoration:none;" runat="server" commandname="Content1" commandargument="1" onclientclick="" onclick="lbContent_Click"> 1
|
<asp:linkbutton id="lbContent2" style="text-decoration:none;" runat="server" commandname="Content2" commandargument="2" onclientclick="" onclick="lbContent_Click"> 2
|
<asp:linkbutton id="lbContent3" style="text-decoration:none;" runat="server" commandname="Content3" commandargument="3" onclientclick="" onclick="lbContent_Click"> 3
|
|
|
|
|
|
|
|
|
Need help. I am trying to add a hyperlinkfield dynamically to a grid view , that works fine until i want to pass a parameter to the string, i get this error
BC30311: Value of type 'String' cannot be converted to '1-dimensional array of String'.
this is the code,
<br />
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<br />
SqlDataSource1.SelectCommand = "SELECT * FROM [products]"<br />
GridView1.DataKeyNames = "pid"<br />
Dim lnk As HyperLinkField<br />
lnk = New HyperLinkField<br />
lnk.DataTextField = "pname"<br />
lnk.NavigateUrl = "home.aspx"<br />
lnk.DataNavigateUrlFields = "pid"<br />
<br />
End Sub<br />
<
<br />
asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" EnableViewState="false"><br />
<Columns><br />
<br />
</Columns><br />
</asp:GridView><br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:vpx_newConnectionString %>"<br />
></asp:SqlDataSource><br />
|
|
|
|
|
Dim x As String() = New String(0) {}
x(0) = "pid"
lnk.DataNavigateUrlFields = x(0)
I didn't get any requirements for the signature
|
|
|
|
|
thank you so much for taking the time to answer, but still not working, i can't believe, i put the code this way
Dim lnk As HyperLinkField<br />
lnk = New HyperLinkField<br />
lnk.DataTextField = "pname"<br />
lnk.NavigateUrl = "home.aspx"<br />
lnk.DataNavigateUrlFormatString = "~/home.aspx?pid={0}"<br />
Dim x As String() = New String(0) {}<br />
x(0) = "pid"<br />
lnk.DataNavigateUrlFields = x(0)<br />
and still, over the last line on x(0) still have the message that says
value of type 'string'cannot be converted to '1 dimensional array of string'
|
|
|
|
|
i mean if i coment this line
lnk.DataNavigateUrlFields = x(0)
it add that hyperlinkfield , but not passing the parameter.
|
|
|
|
|
lnk.DataNavigateUrlFields = x
BTW, set option strction on
set option explicit on
It will force you to write better code.
I didn't get any requirements for the signature
|
|
|
|
|
GridView1.DataKeyNames gets the array of string so GridView1.DataKeyNames="pid" is wrong.
lnk.DataNavigateUrlFields is also gets the array of string so
lnk.DataNavigateUrlFields = x(0) is wrong coz x(0) returns only string
try this
lnk.DataNavigateUrlFields=x
Best regard
Pathan
---------------------------------------------------
|
|
|
|
|
Great, Now works perfectly, Thank you so much to both of you guys.
I will follow your advice , once again thanks
|
|
|
|
|
Hello Developers
I need to count number of users signed in to their account area on current time. Furthermore I need to view information of all users currently onlin.
I think the main problem is handling the event when a user close its window.
Any idea..............!
|
|
|
|
|
Try Google
I didn't get any requirements for the signature
|
|
|
|
|
u can do it open add fiel into the Application and when user log in increase it value by one ,also when the user loged out decrease that varialble
1-when application start
Application.Add("UsersCount",0);
2-when User is logged in
Application["UsersCount"]=(int)Application["UsersCount"]+1;
3-when user logged out
Application["UsersCount"]=(int)Application["UsersCount"]-1;
regards
|
|
|
|
|
And if your user does not log out but simply closes the browser window you have to track the last request time and flush the user out if the last request was earlier than the session timeout.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
wEb GuRu... wrote: I need to count number of users signed in to their account area on current time. Furthermore I need to view information of all users currently onlin.
You can create an application variable that holds all data you need. When each session starts, Session_Start event will be fired on Global.asax . You need to increment your application variable count here. In session_end decrease this value. This is the easy approach. But there are some problems with this
1- Session_End is not reliable
2- It's will be fired only if you are using inproc mode.
I have done this by creating a HTTPModule . For session end, I used cache and set Session timeout for cache. You need to create a delegate for Cache end, this will be similar like your session_end, but reliable.
wEb GuRu... wrote: I think the main problem is handling the event when a user close its window.
This is a common issue. No events will be fired on server when user closes browser. You need to wait till the session/cache ends.
|
|
|
|
|
Hi,
I need your help in my project i am using asp.net ajax toolkit controls, in that calendar control, after selecting the date i want to close that popup calendar window.please anybody help me please...waiting for your reply...
thanks & regards
Alex.
|
|
|
|
|
R you displaying that CalendarExtendar control in same page or another popup window????
use self.close(); method
Best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
hai,
i am using default calendar method.while clicking the textbox calendar control will be displayed just below the textbox....i want to close or disapper that calendar after selecting the date.
the code i wrote is
<cc1:datepickertextbox id="txtLogStartDate" runat="server" onkeydown="return false;" cssclass="entrytext">
<cc2:calendarextender id="defaultCalendarExtender" runat="server" targetcontrolid="txtLogStartDate">
help me ..
alex.
|
|
|
|
|
Where is code?????????????
Best Regard
pathan
---------------------------------------------------
|
|
|
|
|
hai,
I couldn't able to paste the code here...
what i did was
one textbox is added and one CalendarExtender ....i want like after the selection of date that calendar should be invisible.....hope u understand my problem...
regards
alex.
|
|
|
|
|
After selecting date when u press TAB its automatically closed calendar.You have no need any code to close it manually.
see Example here CalendarExtendar
I couldn't able to paste the code here...
Check Ignore HTML tags in this message CheckBox here
Best regard
Pathan
---------------------------------------------------
|
|
|
|
|
<asp:textbox ID="Textbox1" runat="server"></asp:textbox>
<cc2:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="Textbox1" OnClientDateSelectionChanged='hideCalendar'>
</cc2:CalendarExtender>
i want to close the calendar after the selection of date....
|
|
|
|
|
See the exmaple here Calendar for "Calendar with an associated button:"
apply PopupButtonID="button" it will be closed calendar control
best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
hi,
I accept that, but the problem with that control is if we click the button the popup will come then if the user click again into the button the page will refresh that's actualy a fault...
can you help me to solve that with this method that's actually my need.
what i want is the same thing as you told but page will not be refreshed again if we click again into the button..hope you understand my problem...
regards
alex.
|
|
|
|