|
|
11Developer wrote: I want to place captcha image on HTML page by using ASP code not ASP.net code.
Then what you are doing over here ? This ASP.NET Forum. Better ask this query at Web Development Forum !
|
|
|
|
|
11Developer wrote: I want to place captcha image on HTML
Please Ask Your Question in different Forum ..!
This Is Asp.net forum
|
|
|
|
|
It seems, you have joined CP today !! So please read forum guide line before you post anything. Everybody here to help you out !! Deleting messges, down voting message does not help you !!
Please read forum guide line !!!
|
|
|
|
|
Hi all!
I looked and I searched and I came out empty... I am trying to do what should be a straightfoward task: update the value of a HiddenField and use that client side in a script. Here is the scenario:
- User goes to a page that has a Cancel button
- If the user changes anything at all on the page (adds items to a grid, changes textfields, etc.) I want the Cancel button to return a confirmation ("Are you sure you want to continue? Your changes will be lost.")
The elements on the page (textboxes, grid, etc) are all in an AJAX UpdatePanel. The Cancel button calls a javascript function which checks the value of a HiddenField to figure out whether to display the confirmation or not.
So, here's what I have so far:
My Cancel button:
<asp:ImageButton ImageUrl="~/images/ButtonCancel.png" style="float:right" OnClientClick="return RequestMessage();"
ID="btnCancel" CssClass="button" runat="server" OnClick="btnCancel_Click"
CausesValidation="False" />
The javascript function behind the OnClick event:
<script type="text/javascript">
function RequestMessage()
{
if($get("ctl00_BodyPH_ConfirmationMsg").value=="true")
{
return confirm('Are you sure you want to continue? Your changes will be lost.')
}
else
return true;
}
</script>
The HiddenField is defined inside the UpdatePanel:
<asp:HiddenField runat="server" ID="ConfirmationMsg" Value="true" />
And it is registered in the protected override void Render(HtmlTextWriter writer) event:
ScriptManager.RegisterHiddenField(this.Page, ConfirmationMsg.ClientID, "false");
When I look at the code generated on the client side the HiddenField seems to be correctly registered as such:
<input type="hidden" name="ctl00_BodyPH_ConfirmationMsg" id="ctl00_BodyPH_ConfirmationMsg" value="false" />
So everything is good so far. The problem comes when I try to change the value of the HiddenField from various events, such as a simple TextBox_TextChanged event:
protected void txtCustomerID_TextChanged(object sender, EventArgs e)
{
ConfirmationMsg.Value = "true";
loadCustomerInfo(false);
}
The event fires but the value for the HiddenField never changes client side, it always stays "false". How can I updated this value throughout the code so that the confirmation will show correctly?? Or am I going about this the wrong way? Is there a better way of achieving the same task another way?
Thanks very much for any insight into this!
|
|
|
|
|
IMO, server side events should not be used like you did. This can be achieved with a client side script. Hook JS OnChange event handler to the text box and change the hidden text box value inside that.
If you are handling this on client side, you don't even need a hidden text box. A JS variable declared in a script block should do the trick. It acts as a public variable available to the whole page. When text changes, just set the value into this variable.
Ramon Enachescu wrote: if($get("ctl00_BodyPH_ConfirmationMsg").value=="true")
This is bad. You should not hard code client id into the code. Either use ClientId property of the control or $get("ConfirmationMsg", parent_control_id) .
|
|
|
|
|
Thanks Navaneeth,
The reason I went with the server side event is that I have to update this flag from many places, so instead of writing JS for a whole bunch of events (text changed, button clicks, grid events [adding/deleting/updating], etc) I'd rather just set a tiny little flag when I need to . I can't be the first one looking for functionality like this...
And yes sir, no hardcoding, that's there cause I'm still trying out things and this is by no means final code but thanks for noticing .
|
|
|
|
|
In my gridView table
Column 'Issue' has a long string (i.e: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
how can i wrap it so it wont expand my table, or squeez down other columns?
i had tried ItemStyle Wrap="true", but it doesn't work
|
|
|
|
|
The word doesn't wrap if there is no space in between. However you can manually insert <br /> tags on the string by writing a function and call it from the html.
|
|
|
|
|
I'm developing a TabStrip control and am having a bit of an issue with the designer and child controls. Below is the relevant code in regards to the problem (I can provide more if needed).
[ParseChildren(true), PersistChildren(false)]
[ToolboxData("<{0}:TabStrip runat=server></{0}:TabStrip>")]
public class TabStrip : CompositeControl, IPostBackEventHandler
{
private Tab mySelectedTab;
private TabCollection myTabs;
public TabStrip()
{
this.myTabs = new TabCollection(this);
}
[MergableProperty(false)]
public Tab SelectedTab
{
get
{
foreach (Tab tab in this.Tabs)
if (tab.IsSelected)
return tab;
return null;
}
set { value.IsSelected = true; }
}
[PersistenceMode(PersistenceMode.InnerProperty), NotifyParentProperty(true)]
[MergableProperty(false)]
public TabCollection Tabs
{
get { return myTabs; }
}
}
When I add tabs to the Tabs property on a page using the property grid's collection editor the tabs are listed in the collection editor by ID and can also be selected from a drop-down list from the property grid for the SelectedTab property. This is good and is exactly how I want the control to behave in the designer. The problem is, when the page is closed and reopened in the designer, the markup is still there, but when editing the child tabs in the collection editor they are listed by there class name rather than ID, changes made in the collection editor are not persisted, and they are no longer listed in the drop-down for the SelectedTab property. This is no good.
The TabCollection class implements the IList interface and all the Tab 's public properties have the NotifyParentPropertyAttribute set to true. Please advise as to what may be missing for the designer to be aware of the child controls when the page containing the control is reopened. Thank you.
|
|
|
|
|
The designer is evil. Do not use it.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
But I like the designer. Besides, this is a TabStrip that I intend to share. There must be something I'm missing that the CollectionEditor does to make the designer aware of the controls it added that I could implement in the control, but I have no idea what.
|
|
|
|
|
|
Thanks, I added the [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] attribute and that fixed the changes issues (It was there before but I removed it thinking it rendundant to the PersistanceMode , oops). I ended up making a custom UITypeEditor to list the child tabs for the SelectedTab property. That brought to my attention a flaw to the logic of setting that property in the designer since it doesn't know how to persist a control value by it's ID. So I ended up setting the [Browsable(false)] attribute on the SelectedTab property and implementing a SelectedTabID property and using the custom UITypeEditor for that property. It is a bit of a workaroung but all is well now.
I know I've seen a TypeConverter or something out there that can be used to list control ids of a certain type, but can't recall how, nor do I think it would work since the designer is still unaware of the child controls unless added with the CollectionEditor.
Thanks for pointing me to your article, looks like a cool control. I'll have to look closer even though I have already implemented a solution.
|
|
|
|
|
Good. Let me know if you find any flaws in the code.
|
|
|
|
|
|
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="FileControl.ascx.cs" Inherits="Administration_Controls_FileControl" %>
<div style="width: 100%; height: 50px;">
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="test" runat="server" OnClick="test_click" />
</div>
protected void test_click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
}
}
I have this code, but i keep getting HasFile = false ..
Anyone sees what im doing wrong.. I really dont see it.
Thanks. Wouter
|
|
|
|
|
Are you using this fileupload control inside UpdatePanel.
It will not work inside an UpdatePanel, you need to forcefully postback using
<Triggers>
<asp:PostBackTrigger ControlID="test" >
</Triggers>
|
|
|
|
|
Ok thanks , i posted my usercontrolid in the trigger, now it works Thanks!
|
|
|
|
|
Oh, the button is within a Panel. Use this Solution then :
ScriptManager scr = ScriptManager.GetCurrent(this.Page);
if (scr != null)
{
scr.RegisterPostBackControl(this.mycontrol.FindControl("test"));
}
Place this script inside the Page_Load section.
Now click on the Button test and see if the Onclick event inside the Usercontrol gets fired with file in the FileUpload control.
|
|
|
|
|
|
Most welcome.
Dont forget to click "Good Answer" , if it really helped you.
|
|
|
|
|
in webform.aspx has
<% String vdUser = Request.ServerVariables["AUTH_USER"]; %>
...
<asp:sqldatasource id="dg_vendorTrk" runat="server"
="" connectionstring="<%$ ConnectionStrings:conn_vendor_server %>"
...
updatecommand="UPDATE table1 SET vdLogAs=@vdUser WHERE (vdId=@vdId)">
<updateparameters>
<asp:querystringparameter name="vdUser" defaultvalue="<%= Request.ServerVariables[" auth_user"]="" %="">" />
Please HELP, how can i pass a vdUser to either UpdateCommand or UpdateParameters
|
|
|
|
|
Create an
<asp:hiddenfield id="hdnUser" text="<%= this.vdUser %>">
The variable @vdUser, even if you are sending using parameter, the actual value should be specified in the hiddencontrol.
|
|
|
|
|
Thanks Sur
I got the issue solved. Here is how i did:
in PageLoad()
{
System.Web.UI.WebControls.Parameter pm = new System.Web.UI.WebControls.Parameter();
pm.Type = TypeCode.String;
pm.Name = "name";
pm.DefaultValue = HttpContext.Current.User.Identity.Name.ToString();
GridView1.UpdateParameters.Add(pm);
}
|
|
|
|