Redirect to another control DNN - redirect

In my Page_Load event of my custom DNN module I retrieve the settings that I have stored using the following.
if (((string)Settings["username"] != null) && ((string)Settings["username"] != ""))
username = "";
{
username = (string)Settings["username"];
if (((string)Settings["password"] != null) && ((string)Settings["password"] != ""))
{
password = (string)Settings["password"];
}
if (((string)Settings["baseServiceUrl"] != null) && ((string)Settings["baseServiceUrl"] != ""))
{
baseServiceUrl = (string)Settings["baseServiceUrl"];
}
baseServiceUrl = "";
Now my question is how do I redirect it to my module settings(called settings.ascx) control if username, password or baseServiceurl is null.
I'm sure it's not as simple as Response.Redirect('settings.ascx');
my aim is to replace
username = "";
with a snippet similar to Response.Redirect('settings.ascx');
Please help

If you want to load a different ASCX file that is registered in DNN (registered in the Module Definition, via the MANIFEST file) you do so by calling either the EditUrl method, or the NavigateURL Method in DNN.
EditUrl("Settings") where Settings is the ControlKey defined in the Module definition.
Edit URL is available off of PortalModuleBase, assuming your controls inherit from PMB.

Thanks again Chris, your answer is correct but I decided to get the settings of the module via the modal pop up. This is what I did to get the answer to get the javascript popup script and url i right clicked on the gear icon using google chrome an inspected the element.
I then copied the contents the anchor tag href attribute, this looked a bit like
href="javascript:dnnModal.show('http://localhost/TestPage/ctl/Module/ModuleId/417?ReturnURL=/TestPage&popUp=true',/*showReturn*/false,550,950,true,'')">
In my default.aspx page I created an anchor tag without the href. I made it a server control by putting runat=server and adding an ID to it and made the visibility false (in my logic i make it visible if it does not meet my criteria)
<a runat="server" class="btn btn-success" id="settingsLink" visible="false" > <img src="/images/action_settings.gif"><span>Settings</span></a>
Next I create a method to dynamically build my link
private string settingsUrlBuilder()
{
var s = new StringBuilder();
var urlPartArray = TabController.CurrentPage.FullUrl.ToString().Split('/');
var partUrl = urlPartArray[3].ToString();
s.Append("javascript:dnnModal.show('");
s.Append(TabController.CurrentPage.FullUrl.ToString().ToLower());
s.Append("/ctl/Module/ModuleId/" + ModuleId.ToString());
s.Append("?ReturnURL=/");
s.Append(partUrl);
s.Append("&popUp=true");
s.Append("',/*showReturn*/false,550,950,true,'')");
return s.ToString();
}
This is where i use the function in the page load
settingsLink.HRef = settingsUrlBuilder(); settingsLink.Visible = true;

Related

use .net ui automation framework to capture user clicks of links in outlook application

I'm using .net ui automation framework to capture user clicks of links when they are viewing a message in an outlook application.
The problem is that, I'm not able to get the link as an AutomationElement(as I can in a web page in IE window). I can only get the document pane as a whole.
Is there any way to do it?
Well, I got it myself.
Though I'm not able to get the link directly, I can locate the link and get it from the TextPattern of the document element.
Suppose element is the document element that directly gets the focus or clicked:
if (element.Current.LocalizedControlType == "document")
{
var point = new System.Windows.Point(Cursor.Position.X, Cursor.Position.Y);
object textPattern;
if (element.TryGetCurrentPattern(TextPattern.Pattern, out textPattern))
{
var range = ((TextPattern)textPattern).RangeFromPoint(point); //it's an empty range
var e = range.GetEnclosingElement(); //get the enclosing AutomationElement
if (e.Current.LocalizedControlType == "link" || e.Current.LocalizedControlType == "hyperlink")
{
//use e
}
}
}

CQ-Dialog page properties can not be stored from site admin but works from sidekick

The purpose of the following function is to allow the user to save the edited page properties in the CQ-Dialog even though if they invalid by clicking on the button save anyway:
PageProperties.showMsg = function(dialog, config, errorMessage) {
CQ.Ext.MessageBox.buttonText.ok = "save anyway";
CQ.Ext.Msg.show({
title : "Completeness check failed",
msg : errorMessage,
buttons: CQ.Ext.Msg.OKCANCEL,
fn : function(buttons) {
if(buttons == "ok") {
dialog.form.items.each(function(field) {
// clear fields with emptyText so emptyText is not submitted
if (field.emptyText && field.el && field.el.dom && field.el.dom.value == field.emptyText) {
field.setRawValue("");
}
});
var action = new CQ.form.SlingSubmitAction(dialog.form, config);
dialog.form.isValid = function() {
return true;
};
dialog.form.doAction(action);
dialog[dialog.closeAction]();
CQ.Util.reload();
}
}
});
};
This functions works fine from the sidekick. When I click on save anyway all current values of the page properites are stored regardless if they are valid or not. This does not work from the site admin. when I call the page properties of the same page from the site admin and try to save the page properties with invalid values by clicking on save anyway, this does not works (old values are stored and nothing changes).
I hope somebody can help. thank you
I found the solution. the problem was the function CQ.Util.reload(). It prevent storing the values

Page redirection in sharepoint 2010 webpart(sandboxed solution) using c# code is it possible?

I am using a sandboxed solution (sharepoint 2010 project is on office 365 hence using sandboxed solution) and want to go from one page to another on a button click event. This is achieved by javascript but the operations in the click event are not being performed.
For example, I assign the javascript on page load to the desired event then the event performs the redirection without going into the code which is inside the event.
The javascript used for redirection is :
string redirectURL = "http://ksreejit:32512/sites/SplTeam/Pages/QuizMasterDashboard.aspx";
btnCancel.Attributes.Add("OnClick", "javascript:{window.location='" + redirectURL + "';return false;}");
And the event code is:
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (ViewState["QuestionID"].ToString() != string.Empty)
{
SaveDetails(ViewState["QuestionID"].ToString());
foreach (Control contrl in this.Controls)
{
contrl.Visible = false;
}
}
else
{
SaveDetails();
foreach (Control contrl in this.Controls)
{
contrl.Visible = false;
}
}
Label lblMessage = new Label();
lblMessage.Visible = true;
lblMessage.Text = "The Question is successfully saved and sent to reviewer for reviewing. Thanks for uploading.";
}
As you can see the redirection works for btnCancel successfully. I have not assigned it for btnSubmit cos it will then only redirect and will not go to the above specified code.Tried microsoft help they were also clueless.Answers will be appreciated.the project requirement has been modified. long time no answers please check more. Thanks in advance.
Add this code in your button click
string redirectURL = "http://ksreejit:32512/sites/SplTeam/Pages/QuizMasterDashboard.aspx";
this.Controls.Add(new LiteralControl("<script>window.location.href='" + redirectURL + "';</script>"));
For your btnSubmit button, don't add the attribute like you did for your btnCancel.
And then simply add a Response.Redirect(...); in your event method.
... lblMessage.Text = "The Question is successfully saved and sent to reviewer for reviewing. Thanks for uploading.";
Response.Redirect("http://ksreejit:32512/sites/SplTeam/Pages/QuizMasterDashboard.aspx");

How to capture a value not through an input field in a form using php and mysql ?

Hello everybody and good day ,
I am making a web application in php and mysql
Iam trying to make a page where a user can create a custom form eg. User can create custom forms so they can type the name of the input, however the place where they type the name of the input i have it formated like this:
<div contenteditable="true">
<span spellcheck="false" id="a">Editable Content</span><em>o!</em>
</div>
so its not an input field .
How can i capture this information in a form , maybee with a hidden input field, a label or with jquery ?
if my question is not clear let me know i will edit ti it as soon as i get a chance .
You can use javascript to collect the text inside the span.
This question is related How do I change the text of a span element in JavaScript
The answers mention document.getElementById("myspan").innerHTML which is the place that text resides. You'll want to change the "myspan" though.
You have to use either a form or send the data with AJAX.
document.getElementById("your-form").onsubmit = function()
{
var spanInput = document.createElement("input");
spanInput.setAttribute("type", "hidden");
spanInput.setAttribute("name", "spanData");
spanInput.setAttribute("value", document.getElementById("a").innerHTML);
this.appendChild(spanInput);
return true;
}
// or
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){} // please change
xhr.open("POST", "your-script.php");
var spanData = document.getElementById("a").innerHTML;
xhr.send("spanData="+encodeURIComponent(spanData));

Popup browser back to parent browser after a certain page is reached

I have a popup (which I used by necessity) that is opened on a link click. I have the user going through a series of pages picking attributes to then be sent to a shopping cart.
My problem: After the user reaches the end of the selection process i want to kill the open popup and send the request back to the original browser (parent) so the user can checkout.
Any idea how I would do this?
Javascript: in the child (popup) window.
window.opener.location = 'page.html";
window.close();
Is that what your looking for?
The parent window can be accessed using "opener" in JavaScript.
Example:
window.opener.title='hello parent window';
or
window.opener.location.href='http://redirect.address';
Script in my child form:
<script language="JavaScript" type="text/javascript">
function SetData() {
// form validation
// var frmvalidator = new Validator("myForm");
// frmvalidator.addValidation("name","req","Please enter Account Name");
// get the new dialog values
var str1 = document.getElementById("name").value;
var winArgs = str1;
// pass the values back as arguments
window.returnValue = winArgs;
window.close();
document.myForm.submit();
}
</script>
Script in my parent form:
<% #account_head= current_company.account_heads.find_by_name("Sundry Debtors")%>
<script type="text/javascript">
function OpenDialog() {
var winSettings = 'center:yes;resizable:no;help:yes;status:no;dialogWidth:450px;dialogHeight:200px';
// return the dialog control values after passing them as a parameter
winArgs = window.showModalDialog('<%= "/accounts/new?account_head_id=#{#account_head.id} #man" %>', winSettings);
if(winArgs == null) {
window.alert("no data returned!");
} else {
// set the values from what's returned
document.getElementById("to_account_auto_complete").value = winArgs;
}
}
</script>
This is work but not as i want, any one if found good solution please suggest.