|
|
JS Function
<br />
function val(cntrl)<br />
{<br />
if(document.getElementById(cntrl).value=="")<br />
{<br />
return false;<br />
}<br />
}<br />
deepthy.p.m wrote: butSubmit.Attributes.Add("OnClick", "return val()");
<br />
btnsubmit.Attributes.Add("onclick", "return val('" + TextBox1.ClientID + "')")<br />
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
|
Hi Net Experts!
This maybe a simple question for you all, but I have not been able to get it works, I created a web form page .aspx, and a user control file .ascx. Here is the code in my .ascx file
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ControlFormBookSearch.ascx.cs" Inherits="Control_ControlFormBookSearch" %>
<table style="padding:0; border:solid 0px;">
<tr valign="middle">
<td style="vertical-align:top;border-bottom:solid 0px">
Keyword: <asp:TextBox ID="searchValue" runat="server" />
</td>
</tr>
</table>
From my web form .aspx file, I wanted to access the control searchType this way:
<%@ Register src="ControlBookDetail.ascx" tagname="ControlBookDetail" tagprefix="uc9" %>
<script runat="server">
protected void btnSearch_Click(object sender, EventArgs e)
{
TextBox searchValue = (TextBox)Page.FindControl("searchValue");
if (searchValue != null)
Response.Write(searchValue.Text);
else Response.Write("Bad request");
}
But I have not been able to get it to work. Could you please show me how to fix this? thank you for your helps!
-Hai
Hai
modified on Friday, July 4, 2008 1:26 AM
|
|
|
|
|
Did you add the control to the page by using something like below
<br />
<uc9:controlbookdetail id="ID1" runat="server" properties....="" xmlns:uc9="#unknown" /><br />
nguyenhh wrote: protected void btnSearch_Click(object sender, EventArgs e)
{
TextBox searchValue = (TextBox)Page.FindControl("searchValue");
Control searchType = Page.FindControl("searchType"); //never find this control
if (searchValue != null)
Response.Write(searchValue.Text);
else Response.Write("Bad request");
}
This is not the way of using it.
You should write some properties to your control, So that you can directly use your control properties. No need to find each control inside it.
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Sherin Iranimose,
I am learning .net, could you give me some example code to do this the correct way.
my web form file:
<%@ Import NameSpace="com.nangmoi" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Web" %>
<%@ Page Language="C#" MasterPageFile="~/MasterPageHome.master" Title="www.nangmoi.com" %>
<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>
<%@ Register src="Control/ControlFormBookSearch.ascx" tagname="ControlFormBookSearch" tagprefix="uc6" %>
<script runat="server">
private BookManager objManager = new BookManager();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack){
GridView1.DataSource = objManager.getAuthorByAll();
GridView1.DataBind();
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
TextBox searchValue = (TextBox)ControlFormBookSearch1.FindControl("searchValue");
if (searchValue != null)
Response.Write(searchValue.Text);
else Response.Write("Bad request");
}
</script>
<uc6:ControlFormBookSearch ID="ControlFormBookSearch1" runat="server" />
user control page
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ControlFormBookSearch.ascx.cs" Inherits="Control_ControlFormBookSearch" %>
<table style="padding:0; border:solid 0px;">
<tr valign="middle">
<td style="vertical-align:top;border-bottom:solid 0px">
Keyword: <asp:TextBox ID="searchValue" runat="server" value="test" />
</td>
</tr>
</table>
user control code behind:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
public partial class Control_ControlFormBookSearch : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public SearchValue{
get {return searchValue.Text;}
set (searchValue.Text = value;}
}
}
Thanks!
Hai
|
|
|
|
|
This is sample userctrl with textbox inside:
<![CDATA[<%@ Control Language="C#" AutoEventWireup="true" CodeFile="usc1.ascx.cs" Inherits="UI_usc1" %>]]>
<asp:panel id="Panel1" runat="server" xmlns:asp="#unknown">
<asp:textbox id="TextBox1" runat="server"></asp:textbox>
</asp:panel>
This is aspx page i include the user ctrl in this page, i use findcontrol method of usercontrol object, by using this u can find controls inside the usercontrols.
<![CDATA[<%@ Page Language="C#" %>]]>
<![CDATA[
<script runat="server">
protected void btn_Click(object sender, EventArgs e)
{
((TextBox)usrctrl1.FindControl("TextBox1")).Text = "adasd";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<samplectrl:communication id="usrctrl1" runat="server" xmlns:samplectrl="#unknown" />
<asp:button id="btn" runat="server" text="click find and write" onclick="btn_Click" xmlns:asp="#unknown" />
</div>
</form>
</body>
</html>
|
|
|
|
|
viivekk,
Thank you for pointing that out, what I was missing is:
instead of using:
TextBox searchValue = (TextBox)Page.FindControl("searchValue");
I should use:
TextBox searchValue = (TextBox)ControlFormBookSearch1.FindControl("searchValue");
as ControlFormBookSearch1 is the control id i used in my code.
Thanks again.
Hai
|
|
|
|
|
Hi
am trying to avoid sql injection.
i want to check only the input provided by the user and not the
viewstate how to avoid checking the view state .
the code i used is below
public static string[] checklist=
{"@@","declare","delete","drop","fetch","fetch_status",
"sys","sysobjects","syscolumns","execute", "update","truncate"};
void app_BeginRequest(object sender, EventArgs e)
{
HttpRequest Request = (sender as HttpApplication).Context.Request;
foreach (string key in Request.QueryString)
CheckInputform(Request.QueryString[key]);
foreach (string key in Request.Form)
CheckInputform(Request.Form[key]);
}
private void CheckInputform(string parameter)
{
for (int i = 0; i<checklist.length;> {
if ((parameter.IndexOf(checklist[i], StringComparison.OrdinalIgnoreCase) >= 0))
{
HttpContext.Current.Response.Redirect("~/Error.aspx");
}
}
}
Any help
ngrj.
|
|
|
|
|
Don't do it that way. Use parameterised queries (text or stored procs), or a decent data layer.
If you try to use a crappy hackish solution based on using a crap data access solution then expect complaints when Mr Joe Sysiman, or fetchdog69@hotmail.com wants to sign up for your services.
|
|
|
|
|
Thanks for the reply Mark
I will use the methods you suggested.
thanks for the example.
ngrj.
|
|
|
|
|
Hi,
In the wizard control, how to display the Sidebar horizantally at the top of the wizard. The sidebar displaying the steps in hyperlinks. Can we change those hyperlinks into buttons? And also how to distinguish between active step and other steps in the side bar?
Thanks in advance
|
|
|
|
|
i have to create a search form which contain a multi select listbox and 3 more drop down, user will select values from these ands hit search button, how i can create query on fly? i have to do concatenation work OR is there any other option that asp.net or vs2005 wizard support to generate query on the fly.
Thanks
|
|
|
|
|
dream_liner_7e7 wrote: asp.net or vs2005 wizard support to generate query on the fly.
ASP.NET should have nothing to do with SQL. Wizards in VS sure don't. Yes, you CAN write code that uses controls that try to magically generate SQL, but situations like this are where they hit their limits, and using them is always a nasty option.
I'd do something like this: say one of your possible things to search for is a name. I'd write a proc that does something like
AND (tb1.Name == @Name OR @Name = '')
In other words, you pass empty strings for things you don't want to look for, and write a proc that deals with them
This was a SQL question, you should ask those in the SQL forum
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
i think there is something like query builder which is used in case of runtime scenario ... but i m not sure about that .... if u have any idea plz tell .
Thanks
|
|
|
|
|
I have an
<asp:checkboxlist xmlns:asp="#unknown"></asp:checkboxlist> with several asp:listItems and align them to left in the table cell but there is always some gap as you can see in this figure. the text boxes in the above row are correctly aligned.
http://picasaweb.google.com/arunagulla/Devloper/photo#5218822729113407922
can anyone tell me how can i get them correctly aligned to left.
here is my cell with the asp:checkboxlist
<td runat="server" align="left" class="tdContactBoxes">
<asp:CheckBoxList ID="chkContats" runat="server" TextAlign="Right" OnSelectedIndexChanged="Check" CssClass="chkContats">
<asp:ListItem>I am interested in the commercial version of doXtop (Hyper.Net)</asp:ListItem>
<asp:ListItem>I am interested in a joint venture or business partership with doXtop</asp:ListItem>
<asp:ListItem>I am interested in advertising on doXtop</asp:ListItem>
<asp:ListItem>I am interested in the open API of doXtop for development</asp:ListItem>
<asp:ListItem>I am interested in building my content business to doXtop</asp:ListItem>
<asp:ListItem>I am interested in opening a virtual publisher company on doXtop</asp:ListItem>
<asp:ListItem>I want to publish on doXtop and need help</asp:ListItem>
<asp:ListItem>I have a suggestion for improving doXtop</asp:ListItem>
<asp:ListItem>I have questions on doXtop</asp:ListItem>
<asp:ListItem>I want to report an error</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:CheckBoxList>
</td>
thanks
|
|
|
|
|
Try by giving
CellPadding="0" CellSpacing="0"
for the list box.
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
I have a table, i m adding rows in this table through the code-behind (.cs file).
Is there any way to add asp:textbox or asp:Button
in this table through the code-behind ???
The position (row no. in the table) depends on the data present in the xml file...
|
|
|
|
|
Try this
1[^]
2[^]
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
thanx Sherin Iranimose
How to add event handlers to these controls >
|
|
|
|
|
C#
<br />
control_Name.Event_Name += new EventHandler(Function_Name);<br />
vb
<br />
AddHandler control_Name.Event_Name, AddressOf Function_Name<br />
http://support.microsoft.com/kb/317794[^]
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Sherin Iranimose wrote: C#
control_Name.Event_Name += new EventHandler(Function_Name);
Thanx
|
|
|
|
|
But, if your controls are added in page load or later, the event tree won't be built so the events will not fire.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
You are right.
But I have a doubt about 'page load'....
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Christian Graus wrote: But, if your controls are added in page load or later, the event tree won't be built so the events will not fire.
Then, whats the solution ?
where else in the code-behind the controls can be added ?
|
|
|
|