|
|
HTML view
=========
<![CDATA[<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>]]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function SetUniqueRadioButton(nameregex, current)
{
re = new RegExp(nameregex);
for(i = 0; i < document.forms[0].elements.length; i++)
{
elm = document.forms[0].elements[i]
if (elm.type == 'radio')
{
if (re.test(elm.name))
{
elm.checked = false;
}
}
}
current.checked = true;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False" datakeynames="CustomerID" datasourceid="SqlDataSource1" onrowcreated="GridView1_RowCreated">
<columns>
<asp:boundfield datafield="CustomerID" headertext="CustomerID" insertvisible="False">
ReadOnly="True" SortExpression="CustomerID" />
<asp:boundfield datafield="CustomerName" headertext="CustomerName" sortexpression="CustomerName" />
<asp:templatefield headertext="ABC">
<itemtemplate>
<asp:radiobutton id="RadioButton1" runat="server" groupname="rbBox" />
</itemtemplate>
</asp:templatefield>
</asp:boundfield></columns>
</asp:gridview>
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:EmployeeMgmtConnectionString %>">
SelectCommand="SELECT [CustomerID], [CustomerName] FROM [Customers]"></asp:sqldatasource>
</div>
</form>
</body>
</html>
Code-behinded
==============
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) {
string script = "SetUniqueRadioButton('" + GridView1.ClientID + ".*rbBox',this)";
RadioButton rb = (RadioButton)e.Row.FindControl("RadioButton1");
if(rb != null)rb.Attributes.Add("onclick", script);
}
}
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
|
|
|
|
|
Hi all,
I'm using WSE 3.0 in my project to connect a web application to a web
service. I'm using username token for WSE. In some pages where I have upload
file controls I get an exception saying :
The underlying connection was closed: An unexpected error occurred on a
receive.
I have searched online and found that this problem is a well known bug in
.NET 1.1 and I also found a way to solve it by modifying some code in the
reference.cs file of the web service proxy in the web application. However I
didn't manage to find a reference to the problem in .NET 2.0. Is there a way
to access the reference.cs file in a web application developped with .NET
2.0? If not, how can I fix this problem?
I have also tried to turn off the keep-alive option of the website from the
IIS console but that resulted in other behavioral problems. I'm using
Windows Server 2003 with IIS 6.
Ultimately, if there is no way to fix this, can someone direct me towards a
file upload control that I could use that might fix this problem? I am
wondering if this problem is related to another problem I am having: when
uploading files (one or multiple file upload controls on same page) a
timeout occurs where IE shows that it is still waiting for a reply from the
server and nothing happens. If I check the server, I notice that it has
finished processing the request and the database has been populated with the
results but nothing goes back to the IE client.
Thanks for your help,
Talal
-- If this is a post that has been helpful to you, please vote for it. Thank you!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." --Rich Cook
|
|
|
|
|
Hi Friends,
I am using two method onclick of my button.
OnClientClick="ValidateDates() (Client Side Validation Method)
function ValidateDates()
{
//Get both datesvar startDate = eo_GetObject("OpenDatePicker").getSelectedDate();
var startDate = eo_GetObject("ArrivalDatePicker").getSelectedDate() ;
var endDate = eo_GetObject("DepartureDatePicker").getSelectedDate() ;
//Check if both dates are provided
if ((startDate == null) || (endDate == null))
{
alert("Please enter both Arrival and Departure dates.");
return false;
}
if (startDate.valueOf() > endDate.valueOf())
{
alert("The Arrival date must be before the Departure date.");
return false;
}
}
OnClick="addItinerary" Server Side Method
Now i am getting Alert on the Condition But my Server side Method is also being called at same time.
I want it to return when it Gets alert on Client side Validation.
Any suggestions or help would be highly appreciated
Thanks
Menon
Cheers
Menon
|
|
|
|
|
You should add return in onclick event.
For example :
onclick="return ValidateDates();"
|
|
|
|
|
Thank you very much Micheal,
It worked fine for me..
Thanks
Cheers
Menon
|
|
|
|
|
I'm really wondering who did this..
1) no matter whether it's easy or not. It solved other people's problem.
2) It's already 1:10 AM in my country but i'm still reading this forum...
but some people voted down my post... Can you please tell me what wrong with my post? Thanks.
|
|
|
|
|
Mec ... is korrect
Use return where you have called the event
P.S.
|
|
|
|
|
What s the major difference between <div> and <table></table></div>
|
|
|
|
|
The table can have the rows and columns while the DIV can't.
As the differences between table and DIV are so obvious, I think that you might not ask about that. maybe, you are asking about the differences between table layout and Div (float) layout.. Table layout Vs Div layout[^]
|
|
|
|
|
Hi,
I was trying to sort a GridView programitically but my code is throwing an System.StackOverflowException.Please have a look at the code below and reply what wrong I m doing.
protected void GridView2_Sorting(object sender, GridViewSortEventArgs e)
{
GridView2.Sort("CarrierCode", SortDirection.Descending);
}
CarrierCode is the name of a column above.
Thanks.
|
|
|
|
|
You are getting a stack overflow operation because this event occurs when the hyperlink to sort a column is clicked, but before the GridView control handles the sort operation.
GridView.Sorting Event
[^]
What is happening is your GridView2_Sorting function is executing which calls the sort method. This in turn will cause your GridView2_Sorting function to handle the sorting event thus getting stuck in a loop until the stack overflow exception is raised.
See C# GridView Sorting at http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/gridview.aspx[^]
for help with sorting.
Jim
|
|
|
|
|
Hi all,
I have already found the approaches to access server-side controls of a user control (e.g <asp:label> <asp:textbox> ...) on IE,
var obj = document.getElementById('uctAUserConrolID_AServerSideControlID'); //or
var obj = document.getElementById('uctAUserConrolID:AServerSideControlID'); //or
BUT, these approaches don't work on Firefox!!!
please let me know if anyone know the answer.
Thanks
Ming
|
|
|
|
|
Correct me if i'm wrong, but firefox doesn't use getElementbyId, does it?
|
|
|
|
|
Hi,
The firefox do use getElementbyId, because I tried this piece of code below to get the client-side controls within a user control , it works.
var obj = document.getElementById('AClientSideControl');
|
|
|
|
|
By the way,I use the latest version of firefox.
|
|
|
|
|
Firefox uses getElementById .
|
|
|
|
|
It would appear that indeed i am wrong...
|
|
|
|
|
You can view the HTML ViewSource in both IE and Firefox. And find out what the name of your element. then, I think you will get some idea how to get the object of your element in Javascript. If not, can you please the name of your name which is shown in the viewsource of IE and Firefox.
|
|
|
|
|
Hi Michael,
Thanks for your help, I did use the way you suggested. The HTML ViewSource for the asp:net control in both IE and Firefox are actually same:
For Firefox:
<input name="UctLogin1:txtEmail" type="text" id="UctLogin1_txtEmail" />
For IE:
<input name="UctLogin1:txtEmail" type="text" id="UctLogin1_txtEmail" style="width:200px;" />
Regards,
Ming
|
|
|
|
|
var obj = document.getElementById("UctLogin1_txtEmail"); doesn't work? You got the error or got nothing? Have you tried to debug your javascript by using Firebug?
|
|
|
|
|
No, it doesn't work with getElementById, no error shown in Firefox error console.
the result show null. but anyway, getElementsByName works ..
|
|
|
|
|
Hi Michael,
Problems solved, I use getElementsByName with its name in HTML ViewSource instead of ID, it works!
It seems like the getElimentById function still does not work compatiblely with firefox very well.
Regards,
Ming
|
|
|
|
|
okay.. great!
|
|
|
|
|
Oh dear! I just found out what I said was wrong.
getElementById function works as well!!
|
|
|
|