|
if (e.CommandName == "Select")<br />
{<br />
ListBox lb = (ListBox)GridView1.Rows[Convert.ToInt32(e.CommandArgument)].FindControl("ListBox1");<br />
<br />
<br />
}
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.
|
|
|
|
|
How to access ListBox Control in RowEditing event of GridView while ListBox control has put in <EditItemTemplate>
You get the best out of others when you give the best of yourself.
|
|
|
|
|
ListBox lb= (ListBox)GridView1.Rows[e.NewEditIndex].FindControl("ListBox");<br />
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.
|
|
|
|
|
But I'm getting exception like:
Object reference not set to an instance of an object.
thanks
You get the best out of others when you give the best of yourself.
|
|
|
|
|
ListBox lb= (ListBox)GridView1.Rows[e.NewEditIndex].FindControl("id of Listbox ");
|
|
|
|
|
I used ID but getting exception.
thanks for your kind response.
You get the best out of others when you give the best of yourself.
|
|
|
|
|
Hi all,
I have master page. In that i placed a LinkButton(Log Out).
If user clicks on this logout button, i am entering the login & logout information into database and i am deleting temporary folders.
Probem : When user closes Browser window by Closebutton(X), i need to enter the logout information into database & i need to delete temporary folders and files.
I tried the following logic which is suggested by Abhijit Jana.
But its not working.
if any where i went wrong, let me know.
Here is my code
MastrPage:
==========
Default.master(Design)
<%@ Master Language="C#" CodeFile="Default.master.cs" Inherits="Default_master" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type= "text/javascript">
function UpdateDataBase()
{
// Check Browser Close [X] , Alt+F4 , File -> Close
if (window.event.clientX < 0 && window.event.clientY < 0)
{
window.open("DummyPage.aspx?test=test", "OpenWindow_Close_Session", 'left=12000,top=1200,width=10,height=1');
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div class="header">
<h1 style="color: #FFFFFF">Prospecta technologies</h1>
<h2 style="color: #FFFFFF">Proxy Ads Management System</h2>
<div class="nav">
<asp:Label ID="lbl_Welcome" runat="server" Visible="False" Font-Bold="True"
ForeColor="White"></asp:Label>
|
<asp:SiteMapPath id="SiteMapPath1" runat="Server" PathSeparator=" > " RenderCurrentNodeAsLink="true" />
|
<asp:LinkButton ID="hlink_Logout" runat="server"
onclick="hlink_Logout_Click" CausesValidation="False"
ValidationGroup="Click here for Logout" Visible="False">Logout</asp:LinkButton>
</div>
<asp:Menu id="menua" runat="server"
cssclass="menua"
orientation="Horizontal"
maximumdynamicdisplaylevels="0"
skiplinktext=""
staticdisplaylevels="2" >
<Items>
<asp:MenuItem NavigateUrl="~/LoginPage.aspx" Text="Login" Value="Login"
ToolTip="Login">
</asp:MenuItem>
<asp:MenuItem Text="About Us" ToolTip="About Us" Value=" About Us"
NavigateUrl="~/AboutUs.aspx">
</asp:MenuItem>
<asp:MenuItem NavigateUrl="~/ContactUs.aspx" Text="Contact Us"
Value="Contact Us" ToolTip="Contact Us"></asp:MenuItem>
</Items>
</asp:Menu>
</div>
<asp:contentplaceholder id="Main" runat="server" onunload="Main_Unload" />
<div class="footerbg">
<div class="footer">
<asp:Menu id="menub" runat="server"
cssclass="menub"
orientation="Horizontal"
maximumdynamicdisplaylevels="0"
skiplinktext=""
staticdisplaylevels="2" Height="16px" Width="290px" >
<Items>
<asp:MenuItem NavigateUrl="~/LoginPage.aspx" Text="Login" ToolTip="Home"
Value="Home"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/AboutUs.aspx" Text="About Us" ToolTip="About Us"
Value="About Us"></asp:MenuItem>
<asp:MenuItem NavigateUrl="~/ContactUs.aspx" Text="Contact Us"
ToolTip="Contact Us" Value="Contact Us"></asp:MenuItem>
</Items>
</asp:Menu>
</div>
</form>
</body>
</html>
My CodeBlock
Default.master.cs:(The below method is not executing when i closes the browser. I tried by placing break point)
==================
protected void Main_Unload(object sender, EventArgs e)
{
string str = "<script language='javascript'>";
str += "UpdateDataBase();";
str += "</script>";
Page.RegisterStartupScript("test", str);
}
//////////////////////////////
DummyPage.aspx.cs(This is the page i am redirecting to user from javasript method)
PageLoad()
{
if(!Page.IsPostBack)
{
if(Request.QueryString["test"]!="") // I am trying to create a direcory for Checking purpose
{
DirecoryInfo dir = new DirecoryInfo(@"D:\Test");
if(dir.Exists == false)
dir.Create();
}
}
}
..................
Please suggest me where i went wrong.
Thnks in advance.
|
|
|
|
|
sekhar.k wrote: I tried the following logic which is suggested by Abhijit Jana.
But its not working.
becuase your did not implement all the logic , you are done it partialy !!!
sekhar.k wrote:
function UpdateDataBase()
{
// Check Browser Close [X] , Alt+F4 , File -> Close
if (window.event.clientX < 0 && window.event.clientY < 0)
{
window.open("DummyPage.aspx?test=test", "OpenWindow_Close_Session", 'left=12000,top=1200,width=10,height=1');
}
}
<title>
did you call UpdateDataBase this method ever ??
then how the things will go right ??? just call the function from body unload
<body onunload="UpdateDataBase ()"><br />
<form><br />
.............<br />
</form></body>
|
|
|
|
|
Thanks Abhijit, thanks for reply.
I called UpdateDataBse() in MasterPage on Unload event from code behind not from designing.
Default.master.cs:
==================
protected void Main_Unload(object sender, EventArgs e)
{
string str = "<script language='javascript'>";
str += "UpdateDataBase();";
str += "</script>";
Page.RegisterStartupScript("test", str);
}
Ok i will try as u told, Calling method from MasterPage design itself.
I will tell u the result.
|
|
|
|
|
I tried as u told.
<body önunload="UpdateDataBase ()">
<form>
.............
</form></body>
It is not working...
|
|
|
|
|
did you dubug the code?
does Function calling ? give one breakpoint on PageLoad of UpdateDatabase methods check what going wrong.
|
|
|
|
|
Yes i debug the application.
As u told, i called the javascript function in . But how can i place break point to javascript method. Its not allowing. I can put PageLoad but how can trace that javascript method.
I tried Master page Unload event. Calling that method from this event.
When i put break pont here. The statement were executing but nothing is happening. When user closes the browser i cant see this breakpoint.
|
|
|
|
|
I placed that method into script.js file.
I placed a break point on that method.
Its running when user closes the browser.
But the problem is when browser is closed, the value of 'Y' is -ve & 'X' is +ve.
So i modified the condition.
function UpdateDataBase()
{ // Check Browser Close [X] , Alt+F4 , File -> Close
if (window.event.clientX < 0 || window.event.clientY < 0)
{
window.open("DummyPage.aspx?test=test", "OpenWindow_Close_Session", 'left=12000,top=1200,width=10,height=1');
}
}
But even, the 'if' condition is true the control not going into the if block. Its coming out from function(like that condition fails).
I am bit surprized by looking this.
Why the control is not going inside 'if' block.
any help is appreciated,
thanks in advance.
cheers,
sekhar
|
|
|
|
|
i am talking about break point on your dummy page. check the value if clientX and ClientY by the alert message.
if you want to debug javascript
use debugger;
|
|
|
|
|
Thanks Abhijit, thanks for ur feedbacks.
I placed alert() instead of window.open().
I could see the alert message, when user closes the browser.
But when i replace alert() with window.open() nothing was done.
function UpdateDataBase()
{ // Check Browser Close [X] , Alt+F4 , File -> Close
if (window.event.clientX < 0 || window.event.clientY < 0)
{
alert("Are you sure want to close window?"); // Its working
//window.open("DummyPage.aspx?test=test", "OpenWindow_Close_Session", 'left=12000,top=1200,width=10,height=1'); //Its not working
}
}
In PageLoad event of DummyPage.aspx i just trying to create folder to test the window.open() function. But nothing is created even the condition is true.
Is there any mistake in that method ? It wont giving any errors at runtime.
any help is appreciated.
Thanks in advance.
Cheers,
sekhar
|
|
|
|
|
sekhar.k wrote: DummyPage.aspx
do you have this page in your application ? if yes where it is ?
try to open it form server side check its open or not. then go for window.open().
chenge left, top position to 100,100 , check you are seeing the window or not.
check browser settings for popup blocker !!!!
|
|
|
|
|
Thanks Abhijit, thanks for your kind of response.
Yes i have that page in my application it self.
It's opening through Response.Redirect method.
I will ckeck it out win.open by changing left,top positions as u told.
Cheers,
sekhar.
|
|
|
|
|
Thanks abhijit.
I have taken a new sample application to test the above functionality.
I used Ajax ScriptManager control to my page.In that i included Sript path.
I could see the PopUp window. One more issue is, previously the popups were blocked. I changed the internet options.
One more thing which i observed is
we can call server side Page methods from javascript using ajax ScriptManager that also works perfectly. In my openion its better than win.open() method, because we can't change internet options for client systems.
One thing is the PageMethod should be Static and should be WebMethod.
We can do any thing we want. like updating & saving database, deleting files & folders with out changing internet options.
any way abhijit. Thanks for ur suggestions. By ur suggestions i leant new things, thankq so much for that. I solved one of my problem.
Now i have to concentrate on how handle browser <- button after user logouts from site.
Cheers,
sekhar
|
|
|
|
|
Hi all,
I wants not allow user to revisit the previous pages once he logged out.
I am using master page, in that i placed a logout linkbutton.
When user clicks on logout button, i am redirecting user to loginpage.aspx.
In the Design of loginpage.aspx i wrote the following javascript to prevent user to navigate through browser -> & <- buttons.
LoginPage.aspx:
<%@ Page Language="C#" MasterPageFile="~/ProxyAds.master" AutoEventWireup="true"
CodeFile="LoginPage.aspx.cs" Inherits="LoginPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="server">
<script language="javascript" type= "text/javascript">
if (window.history) {
window.history.forward(1);
}
</script>
<div id="home">
//Login Controls here....
</div>
</asp:Content>
.........................
But its not working.
any thing i am doing wrong ?
please suggest me.
thanks in advance.
|
|
|
|
|
In which event you call javascript function?
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.
|
|
|
|
|
I am not calling this in any event.
I placed in LoginPage.aspx design it self, I not placed Javascript in any mehod. I am just checking the condition.
if(window.history) // This will be executed when ever user hits on <-(browser button).
{
window.history.forward(1);
}
I tried the same logic im masterpage, by placing this code in Default.master(in page designing).
Its worked fine. but the probem is it is totally disabling( i mean when user hits <- button he will be there in same page) throughout the application.
But i wants this should only apply after user logouts and tries to hit <- button.(He should see the same page.)
modified on Friday, September 5, 2008 3:33 AM
|
|
|
|
|
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 256: if (dtArea.Rows.Count > 0)
Line 257: {
Line 258: lstCityArea.DataSource = dtArea;
Line 259: lstCityArea.DataTextField = "AreaName";
Line 260: lstCityArea.DataValueField = "AreaID";
Error Line:258
view code:
protected void grdBusScheduling_RowDataBound(object sender, GridViewRowEventArgs e)
{
//grdBusScheduling.Columns[5].Visible = false;
if (e.Row.RowType == DataControlRowType.DataRow)
{
ListBox lstCityArea = new ListBox();
lstCityArea = (ListBox)e.Row.FindControl("lstCityArea");
lstCityArea.Items.Clear();
DataSet ds = new DataSet();
DataTable dtArea = new DataTable();
dtArea = City.LoadCityArea(Convert.ToInt64(ddlCityFrom.SelectedValue), Convert.ToInt64(ddlVendor.SelectedValue));
if (dtArea.Rows.Count > 0)
{
lstCityArea.DataSource = dtArea;
lstCityArea.DataTextField = "AreaName";
lstCityArea.DataValueField = "AreaID";
lstCityArea.DataBind();
lstCityArea.SelectedIndex = 0;
}
}
}
You get the best out of others when you give the best of yourself.
|
|
|
|
|
Concretely where is problem in your code?
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.
|
|
|
|
|
Hi,
I am working with Http Response for file download, then I End the Response by Response.End() function.
After all this I want to close current page by self.close() -javascript function.
but the script registered after Response.End statement does not work.
Help me.
|
|
|
|
|
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
view code:
<asp:GridView ID="grdBusScheduling" runat="server" ForeColor="#333333" DataKeyNames="DetailID" OnRowCommand="grdBusScheduling_RowCommand" OnRowEditing="grdBusScheduling_RowEditing" OnRowDataBound="grdBusScheduling_RowDataBound"
AutoGenerateColumns="False" CellPadding="5" Visible="False" DataSourceID="SqlDataSource1">
<EmptyDataTemplate>
<b>There is no Bus Schedule</b>
</EmptyDataTemplate>
<Columns>
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<%#Eval("ForDate", "{0:dd-MMM-yyyy}")%>
<%--<%#DataBinder.Eval(Container.DataItem,"ForDate", "{0:dd-MMM-yyyy}")%>--%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FareForAdult" HeaderText="Fare For Adult" />
<asp:BoundField DataField="FareForChild" HeaderText="Fare For Child" />
<asp:BoundField DataField="FareForSr" HeaderText="Fare For Senior" />
<%--<asp:BoundField DataField="OpenStatus" HeaderText="Open" />--%>
<asp:TemplateField HeaderText="Open">
<ItemTemplate>
<%#Eval("OpenStatus")%>
</ItemTemplate>
</asp:TemplateField>
<%--Testing--%>
<asp:TemplateField Visible="false" HeaderText="Pick-up Point"><%-- SortExpression="Position" >--%>
<EditItemTemplate>
<asp:ListBox ID="lstCityArea" Width="200" Height="100" runat="server" SelectionMode="multiple" >
<asp:ListItem Value="0" Text="ChandPole"/>
<asp:ListItem Value="1" Text="ChandPole1"/>
<asp:ListItem Value="2" Text="ChandPole2"/>
<asp:ListItem Value="3" Text="ChandPole3"/>
<asp:ListItem Value="0" Text="ChandPole"/>
<asp:ListItem Value="1" Text="ChandPole1"/>
<asp:ListItem Value="2" Text="ChandPole2"/>
<asp:ListItem Value="3" Text="ChandPole3"/>
</asp:ListBox>
</EditItemTemplate>
</asp:TemplateField>
<%--*********--%>
<asp:CommandField ShowEditButton="True" HeaderText="Edit" />
</Columns>
<FooterStyle BackColor="#003366" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#003366" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#003366" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringTravel %>"
SelectCommand="BusDetailSelectByFields" SelectCommandType="StoredProcedure"
UpdateCommand="BusDetailEditByDetailID" UpdateCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="ddlCityFrom" Name="CityFromID" PropertyName="SelectedValue"
Type="Int64" />
<asp:ControlParameter ControlID="ddlCityTo" Name="CityToID" PropertyName="SelectedValue"
Type="Int64" />
<asp:ControlParameter ControlID="ddlBusType" Name="BusTypeID" PropertyName="SelectedValue"
Type="Int64" />
<asp:ControlParameter ControlID="ddlVendor" Name="VendorID" PropertyName="SelectedValue"
Type="Int64" />
<asp:ControlParameter ControlID="ddlBus" Name="BusID" PropertyName="SelectedValue"
Type="Int64" />
<asp:ControlParameter ControlID="Date1" Name="FromDate" PropertyName="Text" Type="DateTime" />
<asp:ControlParameter ControlID="Date2" Name="ToDate" PropertyName="Text" Type="DateTime" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="DetailID" Type="Int64" />
<asp:Parameter Name="FareForAdult" Type="Int64" />
</UpdateParameters>
<UpdateParameters>
<asp:Parameter Name="DetailID" Type="Int64" />
<asp:Parameter Name="FareForChild" Type="Int64" />
</UpdateParameters>
<UpdateParameters>
<asp:Parameter Name="DetailID" Type="Int64" />
<asp:Parameter Name="FareForSr" Type="Int64" />
</UpdateParameters>
<%--<UpdateParameters>
<asp:Parameter Name="DetailID" Type="Int64" />
<asp:Parameter Name="OpenStatus" Type="Double" />
</UpdateParameters>--%>
</asp:SqlDataSource>
You get the best out of others when you give the best of yourself.
|
|
|
|