asp net jquery popup dialog form in asp:formview - asp.net

i have following problem, i am using a popup jquery dialog with asp:formview .
the purpose of this popup is for user to enter a hyperlink which is placed then in textbox control in formview
the popup dialog div is located outside a formview just after body tag
<body style="background-color: #FFFFFF; font-family:Lucida Console;">
<div id="dialog-form" title="sdfdfsdf" style="font-size:14px; ">
<form>
<fieldset>
<label for="link">sdfdf</label>
<input type="text" name="sdfsdf" id="link" size="32" />
</fieldset>
</form>
</div>
<form id="form1" runat="server" style="margin-top:50px;" >
<div>
<asp:FormView ID="FormView1"
.......
<InsertItemTemplate>
...
<sometextbox ...../>
<button id="create-user" class="ui-state-default ui-corner-all">Create link</button>
...
</InsertItemTemplate>
After clicking a button a popup window is shown BUT the page starts to refresh immediately
and of course the popup is then hidden.
If I relocate the button outside the formview - the page is not refreshed, but i need it in formview..
Any idea what to do?

add the following attribute to the button:
onclick="javascript: return false;"

this behavior should not come out because it is a button not submit button.
it seems when it is inside the form view a submit action is attached to it, check your jQuery scripts maybe you mistakenly added onclick submit while attaching the dialog.

I found my answer:
clientId must be used:
FTB_API['<%=FormView1.FindControl("AdminCommentTextBox").ClientID%>'].SetHtml(...)

Related

Drop-down list AutoPostBack is not firing in asp.net

In my asp.net website I have created a user control called GlobalHeader.ascx to make header content consistent throughout the website and put a text box control for search functionality as given below:
<div style="display:none;">
<form id="sample"></form>
</div>
<div>
<form id="cse-search-box" name="cse-search-box" method="get" action="/Search Results.aspx">
<input type="hidden" name="cof" value="FORID:11;NB:1" />
<input type="text" name="q" id="q" class="search-txt" onfocus="if(this.value=='Search')this.value='';" onblur="if(this.value=='')this.value='Search';" value="Search"/>
<input type="submit" name="sa" value="Search" class="search-iocn" />
</form>
Now in child page I'm having a drop-down control having AutoPostBack=true and OnSelectedIndexChanged="DrpdwnListSelectedIndexChanged" i.e. on item change event DrpdwnListSelectedIndexChanged is fired and and show some data just under drop-down list. BUT this functionality is ONLY work when I remove search functionality from Header user control.
<asp:DropDownList runat="server" ID="drpdwnList" AutoPostBack="True" OnSelectedIndexChanged="DrpdwnListSelectedIndexChanged">
</asp:DropDownList>
This means form tag preventing drop-down list AutoPostBack functionality to work.
Why so?
How can I make both functionality work together?
Interesting thing is that If I remove <form id="sample"></form> from top search functionality doesn't work.
Thanks

How do I make my button work by pressing enter?

How do I make my button work by pressing enter?
I created a form button and instead of clicking the "log in" button
Is their a way to make the "enter" button on my computer also click to the "log in" button.
Code from the comments
<form name = "myform"> Password: <input type="password" name="pword"> <input type="button" value="Log In" name="Submit" onclick= "validate()"> </p> </form>
You tag mentions ASP.NET, if you do use ASP.NET the easiest way is to specify Default Button for the form:
<form id="form1" runat="server" defaultbutton="Button1" >
<asp:button ID="Button1" runat="server" text="Button" />
</form>
The example above will specify Button1 as a button that will submit the form when Enter is pressed.
Instead of making your Login Button type "button". I would think just by putting a simple input with the type submit would be the best way. Then anytime you push enter within the text inputs it will automatically submit the data.
<form id="form1" runat="server" defaultbutton="Button1" >
<input type="submit" value="Log In!" />
</form>

Boostrap datetimepicker not triggering asp textbox's onTextChanged event

I can't seem to get my textbox to automatically postback after selecting a date from the bootstrap datetimepicker (Downloaded from here). I stil have to press enter for the event to trigger.
<div class="span3">Date<br />
<div id="datepicker" class="input-append date">
<asp:TextBox ID="txtDate" runat="server" OnTextChanged="txtDate_TextChanged" AutoPostBack="true" />
<span class="add-on">
<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
</span>
</div>
</div>
When you select a datetime the input control not lose focus, so the postback not occur. You can force a postback in the event triggered from the datepicker like (not tested):
el.on('changeDate', function(e) {
__doPostBack('<%= txtDate.ClientId %>','');
});
where el is the element on you bind the datetime picker.
Alternatively you can force a blur like:
el.on('changeDate', function(e) {
$('<%= txtDate.ClientId %>').blur();
});
Ref: http://tarruda.github.io/bootstrap-datetimepicker/

Use asp.net button with a html form

I got a request to add this form to a asp.net control.
I want to use asp.net text box and button to submit the info to the form. (because I have special controls to match the look and feel).
this is the form:
<form name="ccoptin" id="signup" action="http://visitor.r20.constantcontact.com/d.jsp"
target="_blank" method="post">
<input type="hidden" name="llr" value="yyyyyy">
<input type="hidden" name="m" value="xxxxxx">
<input type="hidden" name="p" value="oi">
<label>sign up for new services and promotions:</label>
<input type="text"name="ea" value="" class="text" />
<input type="submit" id="iframe" class="submit"
name="go" value="submit" />
</form>
can this be done?
yes, you can use asp.net Textbox control for html input control and you can put the same styling. e.g.
<asp:TextBox ID="ea" CssClass="text" runat="server"></asp:TextBox>
Button control for html submit button e.g.
<asp:Button ID="iframe" CssClass="submit" runat="server" Text="submit" />
For your input type hidden, you can use asp.net HiddenField Control
<asp:HiddenField ID="llr" runat="server" Value="yyyyyy" />
Yes it can be done . On browser side ASP.NET controls get converted in to HTML even if you use the asp.net button.
Drag and drop asp.net button from toolbox and put attribute id , cssclass , name , text . It will get converted in end to HTML as expected
<asp:Button id="iframe" cssclass="submit"
Text="Submit" runat="server" />
Yeah. You have to consider these notes:
If you want to use ASP.NET controls, you should add runat='server' attribute to your form element. It's because ASP.NET controls (AKA server controls) while rendering check to see if they are get rendered in a server form (VerifyRenderingInServerForm method).
<asp:Hidden control is your replacement for <input type='hidden'
<asp:TextBox control is your replacement for <input type='text'
<asp:Button control is your replacement for <input type='submit'
All of your server controls should have runat='server' attribute
ASP.NET only allows for one form with runat=server, and all of your server controls have to be within a form with runat=server. Nesting forms isn't advisable.
See reference on form nesting:
https://web.archive.org/web/20170420110433/http://anderwald.info/internet/nesting-form-tags-in-xhtml/.
You'll need the form in a different document object - maybe host it in an iframe and conver the mini-form to an ASPX page that you load into the iframe ...

JS callback on asp button

Um, I have this guy:
<div class="buttonRight"><asp:Button ID="btnOK" runat="server" Text="OK" Width="68px"/></div>
which renders out to
<div class="buttonRight">
<input type="submit" name="_$_$pc$pc$tabTO$_$uc0$popupSelectCompetition$btnOK" value="OK" id="____pc_pc_tabTO___uc0_popupSelectCompetition_btnOK" style="width:68px;" /></div>
I need to call some javascript on that button without altering its behavior otherwise. I tried putting an OnClick asp attribute but that seems to be for postbacks to call server code, not passing through a javascript hook to the rendered html.
I also don't understand how the input being type='submit' affects me.
Add your client-side code to the OnClientClick property :
<div class="buttonRight">
<asp:Button ID="btnOK" runat="server" Text="OK" Width="68px"
OnClientClick="alert('client side scripts here');"/>
</div>
OnClick property used for server side events.
Or add onclick attribute to your control like that at code behind :
btnOK.Attributes.Add("onclick", "alert('client side scripts here');");

Resources